Skip to main content
Formatting
Source Link
AdminBee
  • 23.6k
  • 25
  • 55
  • 77

I know there are lots of questions about it but i cantI can't get it working. 

I want to clean a group (for instance rootroot) in /etc/group/etc/group with sedsed or awkawk. So iI need to delete everything after "root:*:0:"root:*:0:

I tried to remove it with:

cat /etc/group | awk '!p;/^root:*:0:/{p=1}'

cat /etc/group | awk '!p;/^root:*:0:/{p=1}' and

cat /etc/group | sed 's/root\:\*\:0\:.*//'

cat /etc/group | sed 's/root\:\*\:0\:.*//'

but sed removes the whole root line.

What am i doing wrong?

I know there are lots of questions about it but i cant 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?

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?

Source Link
Nico
  • 123
  • 2
  • 9

Removing everything after pattern with sed or awk

I know there are lots of questions about it but i cant 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?