Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-09-2013
Registered User
 
Join Date: Apr 2011
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 03-09-2013
Scrutinizer's Avatar
Moderator
 
Join Date: Nov 2008
Location: Amsterdam
Posts: 7,352
Thanks: 144
Thanked 1,756 Times in 1,593 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 03-09-2013
Registered User
 
Join Date: Apr 2011
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
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 01:53 PM.