reading a file
how to get total number of lines in a file
how to read a particular line, eg line 7 in that file. |
less will provide line numbers. You just need to grep what you want.
Or you can use cat and grep. Or vim Best A. Mani |
You can use wc for number lines:
WC http://www.linuxmanpages.com/man1/wc.1.php and sed to show line number: HANDY ONE-LINERS FOR SED http://www.linuxhowtos.org/System/se...m?ref=news.rdf and there's probably other ways to do the same thing, that's the beauty of *nix. :) |
Quote:
Code:
awk 'NR==42' filename Code:
sed -n '42p' filename Code:
head -42 filename | tail -1 |
Btw, the GNU version of cat will number lines for you:
Code:
cat -n filename |
>how to get total number of lines in a file
Check Linux commands for wc command and/or nl command or above mention cat command. or use vim editor >how to read a particular line, eg line 7 in that file. this depends on how you want to approach this problem. You can use vim editor again or you can use tail and head commands which is not really nice solution or you can write Perl script to do it. Hope this helps |
All times are GMT -5. The time now is 03:30 AM. |