我有一个看起来像这样的文件:
[hello] - one
[hello] - two
[hello] - three
[hello] - four
我想删除每一行中的'[hello] - '所以它会给我
one
two
three
four
答案 0 :(得分:1)
试试这个:
cut <filename> -d" " -f3
答案 1 :(得分:0)
我会选择cut
,但这里有一些其他选项:
使用awk
:
$ awk -F' *- *' '{ print $NF }' << EOF
> [hello] - one
> [hello] - two
> [hello] - three
> [hello] - four
> EOF
one
two
three
four
使用sed
:
$ sed 's/^\[hello\] - //' << EOF
> [hello] - one
> [hello] - two
> [hello] - three
> [hello] - four
> EOF
one
two
three
four