Remove First Word in text stream

前端 未结 5 1659
情深已故
情深已故 2020-12-29 03:04

How would I remove the first word from each line of text in a stream? i.e.

$cat myfile 
some text 1
some text 2
some text 3

what I want i

5条回答
  •  旧时难觅i
    2020-12-29 03:25

    To remove the first word, until space no matter how many spaces exist, use: sed 's/[^ ]* *//'

    Example:

    $ cat myfile 
    some text 1
    some  text 2
    some     text 3
    
    $ cat myfile | sed 's/[^ ]* *//'
    text 1
    text 2
    text 3
    

提交回复
热议问题