I know there are lots of questions about it but I can't get it working.
I want to clean a group (for instance root) in /etc/group with sed or awk. So I need to delete everything after root:*:0:
I tried to remove it with:
cat /etc/group | awk '!p;/^root:*:0:/{p=1}'
and
cat /etc/group | sed 's/root\:\*\:0\:.*//'
but sed removes the whole root line.
What am i doing wrong?
everything afterdo you mean a) everything after that string on the line containing it, or b) every line in the file after the line containing that string, or c) everything after that string on the line containing that string plus every line after it, or d) something else? Is the*in your example supposed to be literal or the regexp repetition metachar? Please edit your question to show concise, testable sample input and expected output to help clarify your requirements and give us something we can test a potential solution against.