how to get the number of line of a file?
i want to use a variable to save the number of line of a file~
what is the syntax and command. Thanks |
you could use 'wc -l <file>' to get the number of lines in a file. The same command (wc) can be used to count various things. To store in a variable, you could use this command:
export variable_name=`wc -l filename.txt | awk '{print $1}'` |
Another way, using only awk can be
Code:
variable=$(gawk 'END{print NR}' filename) |
All times are GMT -5. The time now is 07:02 AM. |