Help!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help!
# 1  
Old 08-13-2008
Help!

Hi,

Need some help with regard unix commands that can count the total number of files in a directory and counting the total number of lines in each file.

Cheers
# 2  
Old 08-13-2008
Use "wc" command
to count number of files in directory.
Code:
 ls -l | grep -v total | wc -l

to count number of lines in file
Code:
wc -l filename

Note : Be aware it count blank lines also.

- nilesh
# 3  
Old 08-13-2008
Actually simply ls | grep -vc '^total' would also work.

Simply wc -l * will count lines in each file in the current directory, and print a line for each.

You should note that homework questions are not welcome in these forums.
# 4  
Old 08-13-2008
use the following command to find all the files in current directory and list the no of lines in each file.

find ./ -xtype f -maxdepth 1 | xargs wc -l
# 5  
Old 08-13-2008
Forget to mention one thing.....
Please keep your subject informative which help us in sorting.

- nilesh
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question