user2891460
user2891460

Reputation:

Using SED to remove line from textfile

I had a look around the internet for a line of code which would delete the whole line it found a match on.. So if it found file in the file below it would delete the whole file line.. i.e '13382748 | /root/file', which it does in the console...

/root/file:

13382748 | /root/file
13382749 | /root/test

The command below works in the console (as stated above) but does not work when running the script.

sed --in-place '/$number/d' /root/file

It is the last piece to finally complete my script. The line of code simply does nothing.. Any ideas?

Upvotes: 0

Views: 114

Answers (1)

devnull
devnull

Reputation: 123458

The single quotes prevent variable expansion. Say:

sed --in-place "/$number/d" /root/file

Upvotes: 3

Related Questions