开发者

Interleaving serialized data

开发者 https://www.devze.com 2023-02-03 05:25 出处:网络
With the following input file: rohit mohit sohit 34 45 67 开发者_运维百科I have to create a new file with following:

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

精彩评论

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

关注公众号