[Solved] Need help with script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers [Solved] Need help with script
# 1  
Old 10-24-2011
[Solved] Need help with script

Hi there,

I need to extract the mailid's from the mail.info file, for only the senders who send an email to eg "info@example.com".
To simple grep on the "info@example.com" mailaddress doesn't work because the "from=<$sender>" isn't listed in that grep command.

So I thought to grep on mailid's so I have all the mailid of a given time, then filter the mailid's who are equal to the mailid of the "to=<info@example.com>" section. Then i can filter the $senders emailaddresses. In theory...this should work, but how to translate this in a bash script?

example:
Code:
79A62442AF  testhk03@brab2008.local
79A62442AF  testvw02@brab2008.local
6DF7F442AE  testvw02@brab2008.local
2A222442A4  testvw01@brab2008.local

Above is example filtered mail.info file. In this example mail is send from "testvw02@brab2008.local" to "testhk03@brab2008.local". These have the same ID.
I need $1 and $2 of the MailID's only who have send to "testhk03@brab2008.local".
Thus the line 79A62442AF testvw02@brab2008.local.


Hope someone can help me with this.

Thanks in advanced!

Kind regards,

Roland

---------- Post updated at 09:21 AM ---------- Previous update was at 01:09 AM ----------

Have done scripting today, but still have an issue.

I have a file with only the mailid's and the senders emailaddresses. Mow I want to cat that file and remove only the lines which do not have a double entry in the first column.

Code:
37CE3442AD
37CE3442AD testvw01@brab2008.local
E1D7644209 testvw01@brab2008.local

So remove E1D7644209 testvw01@brab2008.local

Thanks in advanced.

Kind regards,

Roland

Moderator's Comments:
Mod Comment Please use code tags <- click the link!

Last edited by zaxxon; 10-24-2011 at 11:47 AM.. Reason: moved out of programming forum; zaxxon: code tags
# 2  
Old 10-24-2011
input

Hi,

need sample input and sample output..

Cheers,
RangaSmilie
# 3  
Old 10-25-2011
Thanks for your answer, but can you give me an example?
I'm not a scripting guru and I think I need something like awk, but can't get it to work.

Thanks in advanced.

---------- Post updated at 02:02 AM ---------- Previous update was at 12:45 AM ----------

Finally got it by myself!!
So simple and didn't get it to work.
Code:
grep -f file1 file2 | awk '{print $2}'

Thanks

Last edited by vbe; 10-25-2011 at 05:38 AM.. Reason: No reason to not use code tags though (and correct typos...)
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Solved] Need help in editing a script

Hi, I have one script in my cronjob, which is fetching file from a ftp site and making a copy with today's date and time. This is a new setup. There was a instance when test_bill.txt was not present on ftp.xxxx_xxxx.com and when this job ran and did not fetched file, still it send mail of... (5 Replies)
Discussion started by: solaris_1977
5 Replies

2. Shell Programming and Scripting

[Solved] Running a R script with in a shell script

Hi, I do have an R script named KO.R. Basically reads thousands of files, whose name has a pattern that differs at a portion of the file name, List.txt. Row_file1_mile.txt Row_file2_mile.txt Row_file3_mile.txt ... ... Row_file1000_mile.txt Below is a portion of my Rscript that reads... (4 Replies)
Discussion started by: Kanja
4 Replies

3. Shell Programming and Scripting

[Solved] Help with grep script

Hi, I'm having trouble with a script to copy one line out of multiple files in a directory and copy to a file called test. I've tried the code below but it copies one line out of the first file multiple times not one line out of all the files. Would someone help? I'm very new to all this. ... (8 Replies)
Discussion started by: bob101
8 Replies

4. Shell Programming and Scripting

[Solved] Shell script help

Hi fellas, I have a file that contains text something like this SNAPSHOT snap-021ede4a vol-bc3f89c0 completed 2012-11-19T06:05:26+0000 100% 170495546006 850 Created by CreateImage(i-6adc0515) for ami-977dfafe from vol-bc3f89c0 TAG snapshot snap-021ede4a project PAC TAG snapshot... (5 Replies)
Discussion started by: Kashyap
5 Replies

5. Shell Programming and Scripting

[Solved] Looking for script running before I run script again

Good afternoon! I have a script in cron that runs every ten minutes. Normally it only takes a minute or so to complete. However there are times when the amount of data it is looking at is large, and it has taken 20 minutes. So I want for it to look for the script before it starts. I was... (8 Replies)
Discussion started by: brianjb
8 Replies

6. Shell Programming and Scripting

[SOLVED] Script error

Hi all I have a code in unix as SCRNAME=`whence $0 | sed -e 's/\.\///g'` this used to return me this path /data/ds/dpr_ebicm_uat/etl/ but i ran this code in linux as SCRNAME=`/bin/ksh whence $0 | sed -e 's/\.\///g'` and now its returning me blank value in SCRNAME. I am not able... (2 Replies)
Discussion started by: vee_789
2 Replies

7. Shell Programming and Scripting

[Solved] basic script help

I run a command to extract blob file locations in a large log file to another file to remove all the fluff. Example: # tail -50 samtest|grep -i blob|cut -d "'" -f 2 /ASM/archive/20100311/18a7e13f.blob /ASM/archive/20100312/18b5570b.blob # cat outtest.log... (2 Replies)
Discussion started by: catalinawinemxr
2 Replies

8. Shell Programming and Scripting

[solved] merging two files and writing to another file- solved

i have two files as file1: 1 2 3 file2: a b c and the output should be: file3: 1~a 2~b 3~c (1 Reply)
Discussion started by: mlpathir
1 Replies

9. UNIX for Dummies Questions & Answers

[solved] Script creation (how to include options in the script)

Hi guys i have written a script which takes the options given to him and execute itself accordingly. for example if a script name is doctortux then executing doctortux without option should made doctortux to be executed in automatic mode i.e. doctortux -a or if a doctortux is needed to run in... (4 Replies)
Discussion started by: pinga123
4 Replies

10. IP Networking

Domain not solved from script

Hello ! I have a small problem on one of our servers - web server. From scripts (PHP and/or Perl) the domains cannot be solved to an IP address. From console everything works fine but from any sort of script the domain name cannot be solved - no matter is that domain is hosted on the same... (6 Replies)
Discussion started by: Sergiu-IT
6 Replies
Login or Register to Ask a Question