I want to output number of lines in text file.So I am using echo command but I am getting filename along with number of lines when I run the following code:echo $page > ttotal=$(wc -l t)echo $totalOutput:    162 tNote: Number of lines in file t are 162 only.
output a variable value using echo command
bash;shell script;text processing
Whenever you use wc -l FILENAME, it would always print file name along with a number.wc -l /etc/hosts34 /etc/hostsIn order NOT to print the file name, you can use cat and pipe it's output to wc -l as follows:cat /etc/hosts | wc -l34So, in your case, if you could change the total variable to total=$(cat t | wc -l), you should get only a number saved in the variable total.On the other hand, you can use cut or awk in order to extract the number part from the wc -l t part as follows:wc -l t | cut -d   -f1wc -l t | awk '{print $1}'