如何从流中的每行文本中删除第一个单词?即
$cat myfile
some text 1
some text 2
some text 3
Run Code Online (Sandbox Code Playgroud)
我想要的是什么
$cat myfile | magiccommand
text 1
text 2
text 3
Run Code Online (Sandbox Code Playgroud)
我怎么用bash来解决这个问题呢?我可以使用awk'{print $ 2 $ 3 $ 4 $ 5 ....}'但这很麻烦,会导致所有空参数的额外空格.我当时认为sed可能会这样做,但我找不到任何这方面的例子.任何帮助表示赞赏!谢谢!
Ken*_*ent 64
根据您的示例文本,
cut -d' ' -f2- yourFile
Run Code Online (Sandbox Code Playgroud)
应该做的工作.
Yan*_*ard 12
这应该工作:
$ cat test.txt
some text 1
some text 2
some text 3
$ sed -e 's/^\w*\ *//' test.txt
text 1
text 2
text 3
Run Code Online (Sandbox Code Playgroud)
这是一个使用的解决方案 awk
awk '{$1= ""; print $0}' yourfile
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
46265 次 |
最近记录: |