Create shell script to extract unique information from one file to a new file.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Create shell script to extract unique information from one file to a new file.
# 8  
Old 08-09-2011
Code:
zcat http.log.20110801.gz | nawk...

OR
Code:
gunzip -c http.log.20110801.gz | nawk...

OR
Code:
gzip -dc http.log.20110801.gz | nawk ...

This User Gave Thanks to yazu For This Post:
# 9  
Old 08-09-2011
You can use zgrep also

Code:
/user/ahamed> zgrep -o "[^ ]*@[^ ]*" http.log.20110808.gz 
igchung@abc.com
sastria9@abc.com
sastria9@abc.com
sastria9@abc.com
pntcdor1@abc.com
pntcdor1@abc.com
pntcdor1@abc.com
visnet@abc.com
visnet@abc.com
visnet@abc.com
visnet@abc.com
animan86@abc.com

Using sed

Code:
gzip -dc http.log.20110801.gz | sed 's/.*] \(.*@.*com\) .*/\1/g' | sort | uniq



regards,
Ahamed

Last edited by ahamed101; 08-09-2011 at 05:34 AM..
This User Gave Thanks to ahamed101 For This Post:
# 10  
Old 08-09-2011
create shell script to extract unique information from one file to a new file

Quote:
Originally Posted by ravi san
Dear Mr 47,

Please try this simple code for retrieving unique information.

Code:
 
gzip -d http.log.20110808.gz ;cut -d " " -f9  http.log.20110808 |uniq > http.log.20110808_updated

This User Gave Thanks to ravi san For This Post:
# 11  
Old 08-16-2011
my god, you guys are pro. it work now, every one of it. thx guys

---------- Post updated at 05:18 PM ---------- Previous update was at 03:44 PM ----------

another question, I generated this file a2.out, however how can I generate another file from it with only unique email listed?

Code:
more a2.out
116borrul@bx.com
133fird@b.com
147aedzra@.com
152najib@bx.com
154rshakir@bluehyppo.com
154zadzli@bc.com
155buddin@bx.com
Access to this service for 116borrul@bx.com
Access to this service for 133fird@b.com
Access to this service for 147aedzra@b.com
Access to this service for 152najib@bx.com
Access to this service for 154rshakir@b.com
Access to this service for 154zadzli@bc.com
Access to this service for 155buddin@bx.com

should be like this,
Code:
more uniqueemail.out
116borrul@bx.com
133fird@b.com
147aedzra@.com
152najib@bx.com
154rshakir@bluehyppo.com
154zadzli@bc.com
155buddin@bx.com

# 12  
Old 08-18-2011
Try this:

Code:
gzip -dc http.log.20110808.gz | nawk ' /@/ { sub("^.*] ",""); sub(" .*", ""); if(!($0 in E)) print; E[$0]} ' > uniqueemail.out

This User Gave Thanks to Chubler_XL For This Post:
# 13  
Old 08-23-2011
Quote:
Originally Posted by Chubler_XL
Try this:

Code:
gzip -dc http.log.20110808.gz | nawk ' /@/ { sub("^.*] ",""); sub(" .*", ""); if(!($0 in E)) print; E[$0]} ' > uniqueemail.out

my god, its works perfectly thank you so much.
# 14  
Old 08-25-2011
Hi, I have another question,

How to remove any domains(@something.com) in the file structure like this one?
Code:
-bash-3.00# more 30days.out 
user/ris1@yiris.net/INBOX 
user/ris2@giris.net/INBOX 
user/ris3@iris.net/INBOX 
user/ris4@hiris.net/INBOX 
user/str1@eamyx.com/INBOX 
user/str2@amyx.com/INBOX 
user/tg4@titangroup.com/INBOX

output should be like this,
Code:
-bash-3.00# more 30days.out 
user/ris1/INBOX 
user/ris2/INBOX 
user/ris3/INBOX 
user/ris4/INBOX 
user/str1/INBOX 
user/str2/INBOX 
user/tg4/INBOX

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

awk script to extract transcript information from gff3 file

I need help to extract transcript information from gff3 file. Here is the input Chr01 JGI gene 82773 86941 . - . ID=Potri.001G000900;Name=Potri.001G000900 Chr01 JGI mRNA 82793 86530 . - . ID=PAC:27047814;Name=Potri.001G000900.1;pacid=27047814;longest=1;Parent=Potri.001G000900... (6 Replies)
Discussion started by: Maduranga
6 Replies

2. UNIX for Beginners Questions & Answers

TCL script to extract the file name and then create two independent list

I am having one problem as stated below Problem Description I am having some "sv" extension files , I am using "glob" to extract the matching files , Now in these matching files , I need to split them and extract the elements and create different lists. For example set files This... (1 Reply)
Discussion started by: kshitij
1 Replies

3. Shell Programming and Scripting

How to create file and file content based existing information?

Hi Gurus, I am SQL developer and new unix user. I need to create some file and file content based on information in two files. I have one file contains basic information below file1 and another exception file file2. the rule is if "zone' and "cd" in file1 exists in file2, then file name is... (13 Replies)
Discussion started by: Torhong
13 Replies

4. Shell Programming and Scripting

Generate 10000 unique audio file of 2MB each using shell script.

Hi, I want 10000+ unique Audio file of approx 2MB each. How can i generate numerous audio files using shell script. Any tool, command or suggestions are welcome. If i give one audio seed file then can we create numerous unique files with same seed file? Any help is highly appreciable.... (11 Replies)
Discussion started by: sushil.kumar
11 Replies

5. Shell Programming and Scripting

Help with shell script to extract certain information

Hi, I have a file which I need to programmatically split into two files. All the information in the file before pattern "STOP HERE" is to be stripped and output into one file while everything after "STOP HERE" is to be output into a separate file. I would appreciate help on how to do... (8 Replies)
Discussion started by: PTL
8 Replies

6. Shell Programming and Scripting

Shell Script to Dynamically Extract file content based on Parameters from a pdf file

Hi Guru's, I am new to shell scripting. I have a unique requirement: The system generates a single pdf(/tmp/ABC.pdf) file with Invoices for Multiple Customers, the format is something like this: Page1 >> Customer 1 >>Invoice1 + invoice 2 >> Page1 end Page2 >> Customer 2 >>Invoice 3 + Invoice 4... (3 Replies)
Discussion started by: DIps
3 Replies

7. Shell Programming and Scripting

Extract UNIque records from File

Hi, I have a file with 20GB Pipe Delimited file where i have too many duplicate records. I need an awk script to extract the unique records from the file and put it into another file. Kindly help. Thanks, Arun (1 Reply)
Discussion started by: Arun Mishra
1 Replies

8. Shell Programming and Scripting

shell script to sort information in one file

Hi to all, anyway to create shell script to sort informations from one file and create new file with the sorted values? from file 30days.out -bash-3.00# more 30days.out user/str4@kl.com/INBOX user/tg1@johor.com/INBOX user/tg2@kedah.com/INBOX user/tg3@titangroup.com/INBOX... (3 Replies)
Discussion started by: Mr_47
3 Replies

9. UNIX for Dummies Questions & Answers

Extract Unique Values from file

Hello all, I have a file with following sample data 2009-08-26 05:32:01.65 spid5 Process ID 86:214 owns resources that are blocking processes on Scheduler 0. 2009-08-26 05:32:01.65 spid5 Process ID 86:214 owns resources that are blocking processes on Scheduler 0. 2009-08-26... (5 Replies)
Discussion started by: simonsimon
5 Replies

10. Shell Programming and Scripting

Urgent: selecting unique specific content of a file using shell script

Hi, I have a file whose content and format at places is as given below. print coloumn .... coloumn .... coloumn .... skip 1 line print coloumn ... skip 1 line I need to select the following : print coloumn .... coloumn .... coloumn... (2 Replies)
Discussion started by: jisha
2 Replies
Login or Register to Ask a Question