读书人

用sed下令模拟tac

发布时间: 2013-02-18 10:50:49 作者: rapoo

用sed命令模拟tac
原始数据

cat data

This is the header line.
This is the first data line.
This is the second data line.
This is the last line.

tac data

This is the last line.
This is the second data line.
This is the first data line.
This is the header line.

sed -n  '{1!G;h;$p}' data

This is the last line.
This is the second data line.
This is the first data line.
This is the header line.

读书人网 >操作系统

热点推荐