count lines in file to variable

I have a text file in which you need to identify the number of lines that looks like this:

awk '{x + +} END {print x}' filename

The problem is that I do not know how this data to any variable in which then need to continue to work in a cycle for ..

do not know someone help?

Sorry for my English

You mean something like this?

line_no=$(awk '{x++} END {print x}' filename)
echo $line_no

--ahamed

PS : Please use code tags. Thank you for your co-operation.

1 Like

thank you

 
line_no=$(wc -l < filename)

one more in awk ..

$ line_no=$(nawk 'END{print NR}' filename)