Skip to content
Advertisement

How to use sed/awk/grep [closed]

I have a text given below…

tcpmux  1/tcp   0.001995    # TCP Port Service Multiplexer [rfc-1078] 
tcpmux  1/udp   0.001236    # TCP Port Service Multiplexer
compressnet 2/tcp   0.000013    # Management Utility
compressnet 3/tcp   0.001242    # Compression Process
unknown 10/tcp  0.000063

Here i dont want string 0.00… from all lines

How to remove 0.00.. values from text

(i.e) my output wants to be

tcpmux  1/tcp      #TCP Port Service Multiplexer [rfc-1078] 
tcpmux  1/udp      #TCP Port Service Multiplexer

Thanks in advance!

Advertisement

Answer

I think that you don’t need grep in order to get the output that you want. You can filter text using sed.

Supposing that your text is saved in text.txt, you can use sed like this:

sed  's/0.00[0-9]*//' text.txt
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement