Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

Delete characters & find unique IP addresses with port

Shell Programming and Scripting


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 03-09-2013
SunilB2011 SunilB2011 is offline
Registered User
 
Join Date: Apr 2011
Last Activity: 9 March 2013, 5:11 AM EST
Posts: 38
Thanks: 41
Thanked 0 Times in 0 Posts
Delete characters & find unique IP addresses with port

Hi,

I have a file having following content.


Code:
 
<sip:9376507346@97.208.31.7:51088
<sip:9907472291@97.208.31.7:51208
<sip:8103742422@97.208.31.7:51024
<sip:9579892841@97.208.31.7:51080
<sip:9370904222@97.208.31.7:51104
<sip:9327665215@97.208.31.7:51104
<sip:9098364262@97.208.31.7:51024
<sip:9373282166@97.208.31.7:51080
<sip:9098711378@97.208.31.7:51208
<sip:9579892841@97.208.31.7:51080
<sip:9907472291@97.208.31.7:51024
<sip:7803832998@97.208.31.7:51024
<sip:7498816129@97.208.31.7:51080

I want to delete all characters before "@" & then find out the unique IP addresses with port.

Please help me to know how I can do this.

Thanks,
Sunil
Sponsored Links
    #2  
Old Unix and Linux 03-09-2013
Scrutinizer's Unix or Linux Image
Scrutinizer Scrutinizer is offline Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 1 July 2015, 4:21 PM EDT
Location: Amsterdam
Posts: 10,298
Thanks: 346
Thanked 2,717 Times in 2,432 Posts
Try:

Code:
awk -F@ '!A[$0=$2]++' file

The Following User Says Thank You to Scrutinizer For This Useful Post:
SunilB2011 (03-09-2013)
Sponsored Links
    #3  
Old Unix and Linux 03-09-2013
SunilB2011 SunilB2011 is offline
Registered User
 
Join Date: Apr 2011
Last Activity: 9 March 2013, 5:11 AM EST
Posts: 38
Thanks: 41
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Scrutinizer View Post
Try:

Code:
awk -F@ '!A[$0=$2]++' file

Thanks, It worked.
Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Need Script to ZIP/SAVE & then DELETE Log file & DELETE ZIPS older than 12 months zachs Red Hat 7 12-14-2012 01:06 PM
find & remove characters in filenames barrydocks UNIX for Dummies Questions & Answers 19 12-22-2011 04:05 AM
Single/Multiple Line with Special characters - Find & Replace in Unix Script r_sarnayak Shell Programming and Scripting 0 06-02-2010 02:34 AM
get part of file with unique & non-unique string andrewsc Shell Programming and Scripting 5 09-17-2009 03:43 PM
How can I check what port addresses used the application eykyn17 IP Networking 1 02-16-2006 11:58 AM



All times are GMT -4. The time now is 08:57 PM.