Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Delete characters & find unique IP addresses with port

Shell Programming and Scripting


Closed    
 
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: 4 December 2016, 11:37 AM EST
Location: Amsterdam
Posts: 11,101
Thanks: 440
Thanked 3,108 Times in 2,749 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

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 02:06 PM
find & remove characters in filenames barrydocks UNIX for Dummies Questions & Answers 19 12-22-2011 05:05 AM
Single/Multiple Line with Special characters - Find & Replace in Unix Script r_sarnayak Shell Programming and Scripting 0 06-02-2010 03:34 AM
get part of file with unique & non-unique string andrewsc Shell Programming and Scripting 5 09-17-2009 04:43 PM
How can I check what port addresses used the application eykyn17 IP Networking 1 02-16-2006 12:58 PM



All times are GMT -4. The time now is 02:21 PM.