【发布时间】:2015-10-28 07:08:45
【问题描述】:
我在 Unix 中有一个通过命令获取并打印的数据:
line01
line02
line03
line04
line05
line06
line07
line08
line09
line10
line11
line12
我想把它整理出来,使第 10 到 12 行高于第 1 到 9 行。像这样:
line10
line11
line12
line01
line02
line03
line04
line05
line06
line07
line08
line09
我尝试使用
<command that fetches the data> | awk 'NR>=10 || NR<=9'
和
<command that fetches the data> | sed -n -e '4,5p' -e '1,3p'
但它仍然按排序顺序显示。我是 unix 新手,所以我不知道如何正确使用 awk/sed。
附言。这些数据存储在一个变量中,然后由另一个命令处理。所以我需要以这种方式对其进行排序,以便首先处理第 10-12 行。 :)
【问题讨论】: