## (4) display ongoing updates to the given
## log file
tail -f /usr/tmp/logs/daemon_log.txt
上述范例可以动态显示该log文件的动态更新。
假设该服务程序是一直不断的加入动态数据到 /usr/adm/logs/daemon_log.txt 的 log 文件里,在命令列控制窗口中使用 tail ! -f,它将会以一定的时间实时追踪该档的所有更新。 ( -f 的只有在其输入为档案时才能使用 )。
假如你在 tail 后下了多个档案参数,你便能在同一个窗口内一次追踪数个log档:
## track the mail log and the server error log
## at the same time.
tail -f /var/log/mail.log /var/log/apache/error_log
tac -- 反过来串连?
cat倒过来怎么拼? 对啦!! 这就是tac的功能啰~它是把档案的顺序内容反过来串连用的,那么~它都用在什么状况下呢? 任何须要以后进先出的顺序重新排列组件的工作都用得上它! 以下面的指令来说,便是以自最后建立的到最先建立的顺序,列出三个最新建的使用者账号:
# (5) last 3 /etc/passwd records - in reverse
$ tail -3 /etc/passwd | tac
curly:x:1003:100:3rd Stooge:/homes/curly:/bin/ksh
larry:x:1002:100:2nd Stooge:/homes/larry:/bin/ksh
moe:x:1001:100:1st Stooge:/homes/moe:/bin/ksh
nl -- 为输出列加上编号
nl 是一个简单但很好用的编号过滤工具,我在输入的地方下了担屗行辛械木幋a皆靠左,nl 是供了非常多的参数使用,可以定义到很细很细? 熊{序来制定它下帽嗪诺氖涑觯旅媸且恍┎问褂玫姆独得鳎?
# (6) Display the first 4 entries of the password
# file - numbers to be three columns wide and
# padded by zeros.
$ head -4 /etc/passwd | nl -nrz -w3