say I am given this file
username1 username2 username3
I want to delete a line that contains something I say. Like for example:
$ deletestuff abovefile username2 $ cat file username1 username3
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
sed -i to edit in place.
/regexp/d deletes lines matching
sed -i /username2/d file
To match whole lines (so that, for example,
username222 is not also removed) use
$ to anchor the search to start and end of the line.
sed -i '/^username2$/d' file