Quote:
Originally Posted by GrapefruiTgirl
Hi Black Sun, welcome to LQ!
You have resurrected a LONG dead zombie thread here  and I have reported it for a possible move onto its own fresh thread instead.
Meanwhile though, assuming the username is always the first entry, and is always followed by some spaces, you could do this:
Code:
sed -i '/^pp .*/ d' chap-secrets
Sasha
|
Thanks for the warm welcome, Sasha!
Yes, I noticed that it's a very old thread, but old or not, the question seemed to fit to the topic, and Google seems to love pages which are stable and exist for a long time.

mistake? Sorry in this case.
Your solution works like a charm, by the way.
Thank you very much -- I wouldn't have expected to get an answer so soon.
I still have one related question, maybe you have a solution to this one as well. As you might notice, I try to get the deletion of users automated, because using a text editor all the time to go through half a dozen of files is a real hassle.
My other file, let's call it
users.allowed looks like this:
Code:
allow pp
allow ppv
allow cpp
allow hopp
allow flopps
The usernames are unique again, there is no space
after the usernames, and always
exactly one space
between an "allow" and a username. Again, I would like to get the line containing "allow pp" deleted without lynching the other users who happen to have a "pp" in their names, too.
(That's the last file, I promise.)
EDIT: Actually, I think
Code:
awk 'match($0,"allow pp") == 0 {print $0}' FILENAME > NEWFILENAME
should just work fine in this case? Maybe there is a more elegant solution, though? I'll give it a shot, anyway.
2nd EDIT: No, it doesn't work. I had tried this before, doh! It also deletes the line "allow pp
v" that's why I had to dump it ... and because there is no space after the usernames I couldn't use "allow pp " (with a space after the username) either.
So I'd still be looking for a solution.
Thank you!