1.

Solve : How do I count lines on a file??

Answer»

Hello!

Can you pls tell me how I can count LINES from a file and store the numeric value in a variable without including the string part?
I used the wc command but it wasn't useful bse it also stored the string part!
Example, variable=wc -l MYFILE, resulted into 5 myfile.

How can I get it to store only 5?

Pls help...you can count lines and get the number of lines in a few ways
CODE: [Select]wc -l file | cut -d" " -f1
wc -l file | awk '{print $1}'
awk 'END{print NR}' file
grep -c . file
doing homework huh?
Hi and thanks very much for your help!! The code worked!
It's ODD that I lost my dog Scooby a week ago, and now SOMEONE with a username - ghostdog helped me out in my homework!

Thanx again



Discussion

No Comment Found