开发者

Interleaving serialized data

With the following input file:

rohit
mohit
sohit
34
45
67

开发者_运维百科I have to create a new file with following:

rohit 34
mohit 45
sohit 67

by only using paste & sed. Any ideas on how this could be done?


$ paste -d' ' <(sed '3q' input.txt) <(sed -n '4,$p' input.txt)
rohit   34
mohit   45
sohit   67


$ cat input.txt
rohit
mohit
sohit
34
45
67
$ sed -e '/^[^0-9].\+/ d' < input.txt  | paste input.txt - | sed -e '/^[0-9]\+/ d'
rohit   34
mohit   45
sohit   67
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜