How would I remove the first word from each line of text in a stream?
For example,
$ cat myfile some text 1 some text 2 some text 3
I want:
$ cat myfile | magiccommand text 1 text 2 text 3
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.
Using the parameter expansion syntax To remove the first and last character of a string, we can use the parameter expansion syntax ${str:1:-1} in the bash shell.
How to Exclude a Single Word with grep. The most simple way to exclude lines with a string or syntax match is by using grep and the -v flag. The output will be the example. txt text file but excluding any line that contains a string match with “ThisWord”.
-c (column): To cut by character use the -c option. This can be a list of numbers separated comma or a range of numbers separated by hyphen(-). Tabs and backspaces are treated as a character. It is necessary to specify list of character numbers otherwise it gives error with this option.
Based on your example text,
cut -d' ' -f2- yourFile
should do the job.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With