Results 1 to 3 of 3
Hi.I need to do a script that can receive any number of parameters which are file names and return the number of lines every file has.the output should be like ...
- 12-18-2009 #1Just Joined!
- Join Date
- Dec 2009
- Posts
- 2
Shell scripting wc usage
Hi.I need to do a script that can receive any number of parameters which are file names and return the number of lines every file has.the output should be like that "The file nameoffile.txt has 5 lines".From what i have done my output is like "The file nameoffile.txt has 5 nameoffiletxt lines".how can I do the output without printing the name of file after the number of lines.thanks
- 12-18-2009 #2Linux User
- Join Date
- Aug 2006
- Posts
- 458
do your own homework first. what have you tried
- 12-18-2009 #3Just Joined!
- Join Date
- Dec 2009
- Posts
- 2
Here is what I've writen in my script :
#!/bin/bash
for i in $@;do
echo "The file $i has $(wc -l $i) lines"
done
It works but I don't want to display the name of file after the number of lines.


Reply With Quote
