Reputation: 33
I'd like some help please, to remove the source port from this list, i.e. so that I only have the client IP address (not the colon and source port number) and server address and port number.
client 129.0.0.230:49982 server 10.193.75.71:80
client 129.0.0.230:49983 server 10.193.75.71:80
client 129.0.0.230:49986 server 10.193.75.71:80
client 129.0.0.230:49987 server 10.193.75.71:80
client 129.0.0.230:49989 server 10.193.75.71:80
client 129.0.0.230:49990 server 10.193.75.71:80
Upvotes: 2
Views: 93
Reputation: 2219
To remove only the ':client-port' column.
cat <file> | sed 's/\(.*\)\(:[0-9]\{5\}\)\(.*\)/\1\3/g'
OR
sed -i 's/\(.*\)\(:[0-9]\{5\}\)\(.*\)/\1\3/g' <file>
Upvotes: 1
Reputation: 6692
cat test.lst |cut -f1 -d':' && cat test.lst|cut -f3,4 -d' '
It will help to fetch only those data you want to fetch.
Upvotes: 0
Reputation: 241808
You can use sed:
sed -e 's/client \|:.*server//g' input.lst
The expression says: remove "client " and everything between a colon and "server".
Upvotes: 2