Help on these two needed ...!!

Folks

I need help on following two.

Say i am getting two values like this

::1:953 and :::8005

I need to replace "::" (first two colons with a * ).I can get these values in a variable.How to tweak this variable to separate out the way i want? Anything after third ":" should be set to new variable.Anything before third ":" should be checked for "::" and if yes,replaced (or echoed by *).

abhi@myhost:/home/abhi> /bin/netstat -anee --tcp -udp |egrep -v "Active|Proto"
(No info could be read for "-p": geteuid()=24616 but you should be root.)
tcp        0      0 127.0.0.1:20032         0.0.0.0:*               LISTEN      0          7910       -
tcp        0      0 127.0.0.1:199           0.0.0.0:*               LISTEN      0          38112261   -
tcp        0      0 10.132.135.239:427      0.0.0.0:*               LISTEN      0          7441       -
tcp        0      0 53.231.201.253:427      0.0.0.0:*               LISTEN      0          7437       -
tcp        0      0 127.0.0.1:427           0.0.0.0:*               LISTEN      0          7436       -
.
.
.

I am unable to get rid of line starting with "(No.....".
How do i remove this line from comamnd's output?

Regards
Abhi

some thing like this :

/bin/netstat -anee --tcp -udp |egrep -v "Active|Proto|^  \(No" 

or

/bin/netstat -anee --tcp -udp |egrep -v "Active|Proto" | sed -n '2,$p'

or

/bin/netstat -anee --tcp -udp |egrep -v "Active|Proto" |  awk '$0 ~ ! /No/ {print }'

thanks...but none of them worked...!!

check now

:slight_smile:

i saw you missed " but i had tried that and even then it did not work....thanks for trying !!

Regards
Abhi

Ohh.. Ok ..This is what i got :

TES>cat f1
(No info could be read for "-p": geteuid()=24616 but you should be root.)
tcp        0      0 127.0.0.1:20032         0.0.0.0:*               LISTEN      0          7910       -
tcp        0      0 127.0.0.1:199           0.0.0.0:*               LISTEN      0          38112261   -


TES>egrep -v "Active|Proto|^\(No" f1
tcp        0      0 127.0.0.1:20032         0.0.0.0:*               LISTEN      0          7910       -
tcp        0      0 127.0.0.1:199           0.0.0.0:*               LISTEN      0          38112261   -


TES>sed -n '2,$p' f1
tcp        0      0 127.0.0.1:20032         0.0.0.0:*               LISTEN      0          7910       -
tcp        0      0 127.0.0.1:199           0.0.0.0:*               LISTEN      0          38112261   -

TES>awk '$0 ~ ! /No/ {print} ' f1
tcp        0      0 127.0.0.1:20032         0.0.0.0:*               LISTEN      0          7910       -
tcp        0      0 127.0.0.1:199           0.0.0.0:*               LISTEN      0          38112261   -


yeah...it worked coz 'f1' is a file....

i can't use file here... i need o/p directly and once from the command line....

Regards
Abhi

As i can't use the command , i saved the output in a file and tested.

The same will work fine from command line also once you piped your output to this.

i had hoped so...but it isn't....

Regards
Abhi

Any advice on these ?

Regards
Abhi