我有一个看起来像这样的文件:
[hello] - one
[hello] - two
[hello] - three
[hello] - four
我想删除每行中的"[hello] -",这样它就会给我
one
two
three
four
试试这个:
cut <filename> -d" " -f3
我会选择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