head tail
bash-3.00# cat -n g | head -5
1 root console Apr 26 18:52 (:0)
2 root pts/3 Apr 26 18:53 (:0.0)
3 root pts/4 Apr 27 00:09 (:0.0)
4 .:
5 fi
bash-3.00# cat -n g | head -5 | tail -1
5 fi
bash-3.00# cat -n g | tail +5 | head -1
5 fi
1 root console Apr 26 18:52 (:0)
2 root pts/3 Apr 26 18:53 (:0.0)
3 root pts/4 Apr 27 00:09 (:0.0)
4 .:
5 fi
bash-3.00# cat -n g | head -5 | tail -1
5 fi
bash-3.00# cat -n g | tail +5 | head -1
5 fi
$ less +F production.log
Important
log
information
here
Waiting for data... (interrupt to abort)
When not to use less
When you need to watch multiple files at the same time,
tail -f
can actually give you a better output. It will show you something like this:$ tail -f *.txt
==> file1.txt <==
content for first file
==> file2.txt <==
content for second file
==> file3.txt <==
content for third file
When a change happens, it prints the file name and the new content, which is quite handy.
With
less
, it would be like this:$ less +F *.txt
content for first file
It shows the content of just one file at a time. If you want to see what’s happening in the second file, you need to first
Ctrl-c
to go to normal mode, then type :n
to go to the next buffer, and then F
again to go back to the watching mode.
Comments
Post a Comment