2

I want to create an script that deletes few lines from a file containing the following text

you.com
me.ac.id
burger.co.us
manheal.com

If i want to delete this:

burger.co.us

How is the syntax in shell programming??

1 Answer 1

13
sed "/burger.co.us/d" < inputfile > outputfile

will match and delete that line from inputfile and write to outputfile using redirection.

Note that you can't read your input and write to the same file using the above. Instead use the -i field to specify replacement in-place.

See here for more about sed.

Sign up to request clarification or add additional context in comments.

2 Comments

Or sed -i -e "/burger.co.us/d" singlefile to replace in-place.
Yes, I think you should add it to your answer before someone tries to do sed ... < file > file :).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.