Accessing input from another file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Accessing input from another file
# 1  
Old 11-26-2007
Accessing input from another file

Hi,

Let me make it clear, Im having two .lst files.

In 1st file Im having only one column,while in 2nd im having 8 columns.

I need to take the input from 1st file, I need to check the column1 in the first file with the 3rd colmn in the 2 nd file , and only the matching records should only captured.

Like wise i need to process all the records in the 1 st and 2 nd file.

plz help me out.


Thanks,
Mohana Krishnan
# 2  
Old 11-26-2007
Code:
awk 'BEGIN{ while ( getline < "a1" ) { arr[$0]++ } }{ if ( $3 in arr ) print }' a2

Always it would be better if you could post sample input and output needed !

Last edited by matrixmadhan; 11-26-2007 at 03:03 AM.. Reason: sample input and output
# 3  
Old 11-26-2007
thanks for your response,

The matched record should be capturd in the another file.

My 1st file wl be like :

abbi~
abrego~
achen~
ahansen~
aidan~
alanbm~
alanc~
albert1~
albertl~
aliceh~

My sencond fiel will be :

0~Neo Fin Product Management Users~kellyv~
0~Neo Fin Product Management Users~kevinc~
0~Neo Fin Product Management Users~kneff~
0~Neo Fin Product Management Users~krithika~
0~Neo Fin Product Management Users~nilesh~
0~Neo Fin Product Management Users~scruton~

.I need only the matching columns n the 3 rd file.

Last edited by krishnan_6015@y; 11-26-2007 at 03:25 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Removing punctuations from file input or standard input

Just started learning Unix and received my first assignment recently. We haven't learned many commands and honestly, I'm stumped. I'd like to receive assistance/guidance/hints. 1. The problem statement, all variables and given/known data: How do I write a shell script that takes in a file or... (4 Replies)
Discussion started by: fozilla
4 Replies

2. Shell Programming and Scripting

Read input files and merge them in given order and write them to input one param or one file

Dear Friends, I am looking for a shell script to merge input files into one file .. here is my idea: 1st paramter would be outfile file (all input files content) read all input files and merge them to input param 1 ex: if I pass 6 file names to the script then 1st file name as output file... (4 Replies)
Discussion started by: hyd1234
4 Replies

3. Shell Programming and Scripting

XML variable for input in same input file

Dear All , i stuck in one problem executing xml .. i have input xml as <COMMAND name="ARRANGEMENT.WRITE" timestamp="0" so="initial"> <SVLOBJECT> <LONG name="CSP_PMNT_ID" val="-1"/> <MONEY name="CSP_CEILING" amount="0.0" currency="AUD"/> ... (6 Replies)
Discussion started by: arvindng
6 Replies

4. Shell Programming and Scripting

Script to delete files with an input for directories and an input for path/file

Hello, I'm trying to figure out how best to approach this script, and I have very little experience, so I could use all the help I can get. :wall: I regularly need to delete files from many directories. A file with the same name may exist any number of times in different subdirectories.... (3 Replies)
Discussion started by: *ShadowCat*
3 Replies

5. Shell Programming and Scripting

Accessing a variable from another file

HI all, How can i access a variable that is defined in another file as: $$Name= "abhinav; in my script. The catch is that it has 2 $s behind it... Thnaks ---------- Post updated at 10:36 AM ---------- Previous update was at 10:29 AM ---------- the file from which i have to... (0 Replies)
Discussion started by: abhinav192
0 Replies

6. Shell Programming and Scripting

Need script to take input from file, match on it in file 2 and input data

All, I am trying to figure out a script to run in windows that will allow me to match on First column in file1 to 8th Column in File2 then Insert file1 column2 to file2 column4 then create a new file. File1: 12345 Sam 12346 Bob 12347 Bill File2:... (1 Reply)
Discussion started by: darkoth
1 Replies

7. Shell Programming and Scripting

Reading specific contents from 1 input files and appending it to another input file

Hi guys, I am new to AWK and unix scripting. Please see below my problem and let me know if anyone you can help. I have 2 input files (example given below) Input file 2 is a standard file (it will not change) and we have to get the name (second column after comma) from it and append it... (5 Replies)
Discussion started by: sksahu
5 Replies

8. Shell Programming and Scripting

accessing a file on internet

Hi, I need to write a script to read a file on internet (say http://mysite.com/myfile.txt) and save it on the unix machine. can anyone please help me on this? Please note that the file is available only on http site and there is no ftp site for it. Thanks, (1 Reply)
Discussion started by: chetanpc
1 Replies

9. Shell Programming and Scripting

Accessing Variables from .conf file

I can't figure out how to access variables that are stored in a separate file. Can someone let me in on the secret? Please, and thank you. -Kevin (7 Replies)
Discussion started by: wayne1411
7 Replies

10. Shell Programming and Scripting

accessing o an exact line in a file

I want to access exact line in a file (sh script) for example I have a variable input and I want to access input.th line in file. for example line 5 or 7. (2 Replies)
Discussion started by: walnut
2 Replies
Login or Register to Ask a Question