Hi ,guys. I have one question:
I want to write a script which removes a line with certain string from a file, for example
The name of the file is: "passwd", the contents of it is below:
*************************
...
brownj2:x:5000:
hynesp:x:5001:
leeb:x:5002
dioxna:x:5003
...
*************************
I want to remove the line with "brownj2" from the file.
Here is my code:
user="brownj2"
sed '/^user:/'d passwd
But, this does not work
Firstly, line with "brownj2" is not removed.
Secondly, I got all the contents in passwd shown up in the terminal, which is not what I want
Can anybody help me with this?
Thank you very much for your time in advance.
-Keyang