wc -l command and playing with it
Hey everyone,
I program which at one point reads the lines in a data file using the command: wc -l file_name With output like: 10000 file_name In the same program, I would like the program to recognize the line count, in this example, 10000, and print to the screen: "Your line count is, 10000". Is this possible in a relatively simple manner? First the program would have to identify the 10000 portion from the 10000 file_name, and then store it. Any ideas? |
Code:
echo "Your line count is: $( wc -l < filename )" look at the bash manual, or the bash how-to on www.tldp.org Cheers, Tink |
Code:
echo Your line count is, `wc -l <file_name> | cut -d ' ' -f 1` |
Thanks guys.
I will read that manual. |
In checking some literature, I'm still not sure exactly what it's called that I am trying to do. Sorry, I'm not very familiar with the terminology yet.
As you recommended, this works: Code:
echo "Your line count is: $( wc -l < filename )" Later in the code, I will call on $linecount. Can this be done? The closest thing I can find in guides it the echo "statement" read Which seems to only be useful if the user is going to input the variable. |
Nevermind. I didn't realize how easy it was and how nonsensical my followup question was.
I didn't realize I could just declare the variable with that command: variable=$( wc -l < $RAWTAGFILEDIR/$OUTDIR/$FILTEREDRAWTAGFILE ) Very good to know, thanks guys. |
Well do :}
Cheers, Tink |
All times are GMT -5. The time now is 06:54 PM. |