Yahoo Interview Question
Software Engineer / DevelopersIf we use wc -l then the output will consist the number of lines with the file path.
Suppose "yourfile" has 1000 lines. So the output of
wc -l yourfile will be
1000 yourfile
To avoid this we can use the pipe.
cat yourfile | wc -l
To store the output in a file we can use
cat yourfile | wc -l > xx
NB: Thanks to goursaha (my best friend) giving me this answer which I thought to be posted here.
wc -l yourfile
- Anonymous October 31, 2009