Samuel
Samuel

Reputation: 328

Removing some text in a file using the terminal

I have a text file consisting of multiple lines like:

Blah blah blah Get_Rid_of_this
Blah blah blah blah blah blah
blah blah blah blah the end

For some reason, I need to remove the "Get_Rid_of_this" part. Please don't ask me to just remove the Get_Rid_of_this part manually, it's kinda complicated.

I was thinking of using the head command to get the first line and then use sed or something to remove that part, but how do I save the file back?

Can somebody help?

Upvotes: 2

Views: 4354

Answers (1)

Arnab Nandy
Arnab Nandy

Reputation: 6702

Use this sed command for removing Get_Rid_of_this words from your input file,

sed -i 's/Get_Rid_of_this//g' input

Upvotes: 3

Related Questions