Saturday, August 22, 2009

The lines

If you want to check how many lines the file has, use wc -l command:

$ cat /etc/shells | wc -l
6

To see the content of the file along with line numbers use cat -n:

$ cat -n /etc/shells
1 /bin/bash
2 /bin/tcsh
3 /bin/csh
4 /bin/ash
5 /bin/ksh
6 /bin/zsh

To get the particular line from the file use head and tail. To see the 4th line from /etc/shells, type:

$ cat /etc/shells | head -4 | tail -1
/bin/ash

No comments:

Post a Comment