How to convert rows to columns in unix

前端 未结 5 1066
离开以前
离开以前 2021-01-03 12:50

I want my Unix file output, which has each value output on a new line, to be converted into grouped rows as shown below.

Say my output file in Unix looks like this:

5条回答
  •  长情又很酷
    2021-01-03 13:02

    Kind of ugly, but doesn't require a shell script:

    cat outputfile | tr "\n" " " | sed -e 's/\W*\(\w*\) \(\w*\) \(\w*\) \(\w*\)\W*/\1 \2 \3 \4\n/g'
    

提交回复
热议问题