bash: shortest way to get n-th column of output

后端 未结 8 1993
春和景丽
春和景丽 2020-11-28 03:29

Let\'s say that during your workday you repeatedly encounter the following form of columnized output from some command in bash (in my case from executing svn st

8条回答
  •  盖世英雄少女心
    2020-11-28 03:55

    You can use cut to access the second field:

    cut -f2
    

    Edit: Sorry, didn't realise that SVN doesn't use tabs in its output, so that's a bit useless. You can tailor cut to the output but it's a bit fragile - something like cut -c 10- would work, but the exact value will depend on your setup.

    Another option is something like: sed 's/.\s\+//'

提交回复
热议问题