Use space as a delimiter with cut command

前端 未结 8 1172
[愿得一人]
[愿得一人] 2020-12-07 07:24

I want to use space as a delimiter with the cut command.

What syntax can I use for this?

8条回答
  •  心在旅途
    2020-12-07 08:28

    You can't do it easily with cut if the data has for example multiple spaces. I have found it useful to normalize input for easier processing. One trick is to use sed for normalization as below.

    echo -e "foor\t \t bar" | sed 's:\s\+:\t:g' | cut -f2  #bar
    

提交回复
热议问题