How to specify more spaces for the delimiter using cut?

前端 未结 12 651
遥遥无期
遥遥无期 2020-12-04 05:51

Is there any way to specify a field delimiter for more spaces with the cut command? (like \" \"+) ? For example: In the following string, I like to reach value \'3744\', wha

12条回答
  •  一整个雨季
    2020-12-04 06:10

    awk version is probably the best way to go, but you can also use cut if you firstly squeeze the repeats with tr:

    ps axu | grep jbos[s] | tr -s ' ' | cut -d' ' -f5
    #        ^^^^^^^^^^^^   ^^^^^^^^^   ^^^^^^^^^^^^^
    #              |            |             |
    #              |            |       get 5th field
    #              |            |
    #              |        squeeze spaces
    #              |
    #        avoid grep itself to appear in the list
    

提交回复
热议问题