i am new to shell scripting and i found following line of code in a given script.
could someone explain me what does the following lines of codes means
-
_filecount=echo ${_filelist} | wc -w | awk '{ print $1 }' -
printk "archiveWLS(): ${_filecount} file(s)"
Thanks in advance for any help
wc -w: wc is word-count, wordcount counts words, lines, characters and so on, -w only outputs the word count.The output is piped to awk, to print only the first word of output. If you use
the filename would be printed, and it would make sense to strip it away with awk. Doing it with a piped output, where there is no filename, is superflous.
As assignment, the line should instead be:
Without $(…) or backticks, it doesn’t work, and filecount is just assigned the word “echo”. Seems like a poorly written script.
printk isn’t defined in bash, nor is it a well established gnu programm from the coreutils.
Maybe it is defined in the script itself.