How to remove the first part of a string in bash?

前端 未结 5 821
一向
一向 2021-02-07 05:48

This code will give the first part, but how to remove it, and get the whole string without the first part?

echo \"first second third etc\"|cut -d \" \" -f1
         


        
5条回答
  •  情话喂你
    2021-02-07 06:03

    Try doing this :

    echo "first second third etc"|cut -d " " -f2-
    

    It's explained in

     man cut | less +/N-
    

    N- from N'th byte, character or field, to end of line

    As far of you have the bash tag, you can use bash parameter expansion like this :

    x="first second third etc"
    echo ${x#* }
    

提交回复
热议问题