Shell/Bash: shell script to count number of lines in a file Example

By

Shell/Bash Example: This is the "shell script to count number of lines in a file" Example. compiled from many sources on the internet by SimpleTutorials.org

shell script to count number of lines in a file

echo Enter the filename
read file
w=`cat $file | wc -w`
c=`cat $file | wc -c`
l=`grep -c "." $file`
echo Number of characters in $file is $c
echo Number of words in $file is $w
echo Number of lines in $file is $l

shell count number of lines

$ wc -l < /dir/file.txt
3272485



* Summary: This "shell script to count number of lines in a file" Shell/Bash Example is compiled from the internet. If you have any questions, please leave a comment. Thank you!

Others