Reputation: 1141
I have a file with the following structure:
prefix_postfix123456 some text1 other stuff
prefix_postfix88989898 some text2 other stuff
I want to replace all prefix* to prefix, and keep the rest of the file as is:
prefix some text1 other stuff
prefix some text2 other stuff
I have try this:
sed -i 's/prefix[\s]*/prefix/g' fileName
But this doesn't work.
Could you please show me how can I do that?
Upvotes: 0
Views: 47
Reputation: 5092
Try this simple method
sed 's/_[^ ]\+//' FileName
OutPut:
prefix some text1 other stuff
prefix some text2 other stuff
Upvotes: 1
Reputation: 3877
Assuming that your data is separated by spaces, then this should do what you want:
sed -i 's/\bprefix[^ ]*/prefix/g' fileName
Upvotes: 1