用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.

猜你喜欢

转载自jobar.iteye.com/blog/1782757