UrgentPlease: compare 1 value with file values eliminating special characters


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting UrgentPlease: compare 1 value with file values eliminating special characters
# 1  
Old 04-25-2008
UrgentPlease: compare 1 value with file values eliminating special characters

Hi All,

I have file

i have values like
----
112
113
109
112
109

I have another file
cat supplierDetails.txt
-------------------------
112|MIMUS|krishnaveni@google.com
113|MIMIRE|krishnaveni@google.com
114|MIMCHN|krishnaveni@google.com
115|CEL|krishnaveni@google.com
108|UGEN|krishnaveni@google.com
109|SLAND|krishnaveni@google.com



I need to compare above values to this file first column values
like
if 112=112 then
i need to print MIMUS
like i need to validate above all values to this file,
I need it in loop

Please help me


Thanks
Krish.
# 2  
Old 04-25-2008
Code:
awk -F"|" 'NR==FNR{arr[$0];next}$1 in arr{print $2}' file1 upplierDetails.txt

Regards
# 3  
Old 04-25-2008
Code:
for val in `cat file1`
do
grep $val supplierList.txt | awk -F"|" '{print $1,$2}' 
done

# 4  
Old 04-25-2008
Hi,

Once i got the values
i need to mail this result like
mail -s "Gateway messaging: $2" krish@google.com

is it possible

please answer it.

Thanks krish.
# 5  
Old 04-25-2008
U can redirect the printed values to a file
i.e
Code:
grep $val file2 | awk -F"|" '{print $1,$2}' >>tempfile

and later use

Code:
mailx  -s "Gateway messaging:" -r  krish@google.com < tempfile

# 6  
Old 04-25-2008
i used mailx is not working

again i used this one
mail -s "Gateway : $2" $Email < $tempfile

it says that

exam5.sh: line 4: $tempfile: ambiguous redirect

Is there any other option
# 7  
Old 04-25-2008
My requirement is
112|MIMUS|krishnaveni@google.com

if val =112
then i need to send mail to
subject:MIMUS mail to Krishnaveni@google.com

is it possible

if val=113
then i need to send mail to
subject=MIMIRE mail to krish@google.com

i need it like this

Can you help me how to do this.

thanks
krish.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep a particular string from column eliminating characters at the end.

Hi, So basically I have this file containing query output in seperated columns. In particular column I have the below strings: news news-prio I am trying to grep the string news without listing news-prio aswell. I tried grep "$MSG_TYPE" , grep -w "$MSG_TYPE" , grep... (4 Replies)
Discussion started by: nms
4 Replies

2. Shell Programming and Scripting

Substitute special Characters into a file

Hi experts :) I need to replace special characters into a file , in the followiing way : " --> "" ' --> '' _--> \_ I tried with the sed command but I'm getting and error ksh: $: not found. ksh: $: not found. sed: Function s/\/\/ cannot be parsed. Any idea ? Thanks , KOLAS... (2 Replies)
Discussion started by: Kolas79
2 Replies

3. Shell Programming and Scripting

File containing special characters

Hello All, I am facing challenges in order to transfer a file from windows to unix box,the file contains a special character '×' ,now when I am transferring the file from windows to unix that special character converted to something else like 'Ã' ,another thing I have noticed that the hardware is... (1 Reply)
Discussion started by: prarat
1 Replies

4. UNIX for Dummies Questions & Answers

Eliminating entries based on relative values

I have posted this before but did not get much feedback. So I will try again. I need to remove sequences from a file based on values listed on a second file. The sequences file looks like this: Sequences.txt >Sample1 Freq 59 ggatatgatgatgaactggt >Sample1 Freq 54 ggatatgatgttgaactggt... (4 Replies)
Discussion started by: Xterra
4 Replies

5. Shell Programming and Scripting

Shell : eliminating zero values and printing

I have a log file containing the below data and should have the output file as below. and the output file should not contain any 0 values. Eg. It should not contain 0000000:0000000 in it. input.txt Media200.5.5.1 00010003:065D1202 Media100.5.5.2 7,588,666,067,931,543... (6 Replies)
Discussion started by: scriptscript
6 Replies

6. Shell Programming and Scripting

Compare values in two files. For matching rows print corresponding values from File 1 in File2.

- I have two files (File 1 and File 2) and the contents of the files are mentioned below. - I am trying to compare the values of Column1 of File1 with Column1 of File2. If a match is found, print the corresponding value from Column2 of File1 in Column5 of File2. - I tried to modify and use... (10 Replies)
Discussion started by: Santoshbn
10 Replies

7. HP-UX

Eliminating characters between two expressions

Hi I have to eliminate all characters between ^ and a space in a file. Following lines - Test ^ H^@^@^@^@^@^@^B^VDM-BM-$|M-^_M-F^AM- File1 Test^H^@^@^@^@^@^F^A^X^@^SM-s^TM-3M-G^A File2 Should be printed as below Test File1 Test File2 I used sed '/^/,/ /d' command, but it is not working.... (1 Reply)
Discussion started by: arsheshadri
1 Replies

8. Shell Programming and Scripting

Removing special characters in file

I have file special.txt with the following data. <header info> 123$ty5%98&0asd 1@356fgbv78 09*&^5jkns43( ...........some more rows. In my output file, I want to eliminate all the special characters in my file and I want all other data. need some help. (6 Replies)
Discussion started by: srivsn
6 Replies

9. UNIX for Dummies Questions & Answers

How to delete a file with special characters

I don't now exactly how I did it, but I created a file named " -C " cexdi:/home1 $ls -lt total 1801336 -rw------- 1 cexdi ced-group 922275840 23 mars 10:03 -C How do I delete this file ? cexdi:/home1 $rm -C rm: invalid option -- C Syntax : rm filename ... Doesn't work...... (5 Replies)
Discussion started by: yveslagace
5 Replies

10. UNIX for Dummies Questions & Answers

how to see special characters in a file using vi

Hi, I have a file which has special characters. I can't see them when I "vi" the file. But I am sure there are some special un seen characters. How can I see them? Please help. Thx (6 Replies)
Discussion started by: jingi1234
6 Replies
Login or Register to Ask a Question