Reputation: 7143
i am not much familiar in scripting. it can be very easy problem. I want to remove first token of every file.
file 1
1 this is good
file 2
2 this is another file.
i would like to remove 1 and 2 from file 1 and file 2. how would do it? any bash command for it?
Upvotes: 1
Views: 77
Reputation: 366
Or with awk:
$ awk '{if (NR==1) {$1="";print $0;} else print $0}' input_file
(This preserves the space at the start of the line)
Upvotes: 2
Reputation: 98048
Using sed and assuming you don't want to preserve a leading space:
sed '1{s/\s*\w*//}' input_file
This will works on the very first line (1{}
) and uses substitute command (s/pattern/replace/
) to delete the first white spaces and following word characters (\s*\w*
). The word characters are [a-zA-Z0-9].
Upvotes: 1