删除文本流中的第一个单词 [英] Remove the first word in a text stream
本文介绍了删除文本流中的第一个单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从流中的每一行文本中删除第一个单词?
How would I remove the first word from each line of text in a stream?
例如
$ cat myfile
some text 1
some text 2
some text 3
我想要:
$ cat myfile | magiccommand
text 1
text 2
text 3
我将如何使用 Bash 解决这个问题?我可以使用 awk '{print $2 $3 $4 $5 ....}'
,但这很麻烦,并且会导致所有空参数都有额外的空间.我在想 sed 可能能够做到这一点,但我找不到任何这样的例子.
How would I go about this using Bash? I could use awk '{print $2 $3 $4 $5 ....}'
, but that's messy and would result in extra spaces for all null arguments. I was thinking that sed might be able to do this, but I could not find any examples of this.
推荐答案
根据您的示例文本,
cut -d' ' -f2- yourFile
应该完成这项工作.
这篇关于删除文本流中的第一个单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文