Making file with values from different files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Making file with values from different files
# 1  
Old 10-06-2008
Making file with values from different files

Hello,

I am stuck up in middle of a script.Pls have a look at the problem and help me in any way out for the same.

There are n number of files with n number of contents in a column.
for example :
file1 has contents in quotes
"abcd"
"1234-asbcd"
"12312".....

file2 has contents in quotes
"123csdfd"
"qwdqdq"
"qweqe"......

file3 has contents in quotes
"123csdfQ13"
"qwdqd12"
"qweqe111"......

and so on ........

The desired output which is expected is as below :
output file -----
fileoutput.abcd,NAME="abcd",ID="123csdfd",DESC="123csdfQ13";
fileoutput.abcd,NAME="1234-asbcd",ID="qwdqdq",DESC="qwdqd12";
fileoutput.abcd,NAME="12312",ID="qweqe",DESC="qweqe111";
.......
and so on .


I have tried many things like while loop, for loop but got no success

can anyone pls help urgently

Thanks inadvance
Aparna
# 2  
Old 10-06-2008
Try with file descriptors.

Code:
exec 4<file1 5<file2 6<file3
while read name; do
  read id <&5
  read desc <&6
  echo "fileoutput.abcd,NAME=$name,ID=$id,DESC=$desc;"
done <&2 >output   # BUG: should be <&4


Last edited by era; 10-06-2008 at 04:49 AM.. Reason: Note bug
# 3  
Old 10-06-2008
Thanks but no success

Hi era,

I tried the solution given by you but no success,
the code hangs and doesn't comes out to shell prompt.

Pls suggest somthg

Thanks
# 4  
Old 10-06-2008
Oops, sorry, the last one after done should be <&4

My bad )-:
# 5  
Old 10-06-2008
Thanks a lot Era

HI Era,

Thanks a lot it Worked for me Smilie

MANY MANY THKS TO U

Tc- Aparna
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace two values in a file with input from two different files

Hi, I was having the following issue cat input hello1, my name is unix.com. I am awesome. Hope you know this, hello2! cat hello1.txt Hi Friends Hi Folks Hi Well-Wishers cat hello2.txt Honey Sweety Darling Required Output (8 Replies)
Discussion started by: jacobs.smith
8 Replies

2. Shell Programming and Scripting

Query the table and return values to shell script and search result values from another files.

Hi, I need a shell script, which would search the result values from another files. 1)execute " select column1 from table_name" query on the table. 2)Based on the result, need to be grep from .wft files. could please explain about this.Below is the way i am using. #!/bin/sh... (4 Replies)
Discussion started by: Rami Reddy
4 Replies

3. Shell Programming and Scripting

How to add values of two files and result in third file

Hi, I am new to shellscripting, I have two files as below File1: Abcdefg110111xyza000000600000000024.020000060000000000024.020000004660000000003.41000000000010000000100.000000000123 File 2:... (3 Replies)
Discussion started by: rajendrabujji
3 Replies

4. 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

5. Shell Programming and Scripting

Cat Values from Several files if it meets criteria for column values

I have results from some statistical analyses. The format of the results are as given below: I want to select lines that have a p-value (last column) less than 0.05 from all the results files (*.results) and cat to a new results file. It would be very nice if a new column is added that tells... (2 Replies)
Discussion started by: genehunter
2 Replies

6. Shell Programming and Scripting

Putting together all values from different files in one file

Hi All, This is what I am trying to achieve but to no avail. I have three sets of files which are: 1. One big dictionary file which looks like this: apple orange computer pear country 2. Some thousands of text files which are named as 1.dat, 2.dat, 3.dat etc The text files... (2 Replies)
Discussion started by: shoaibjameel123
2 Replies

7. UNIX for Advanced & Expert Users

Parse text file values and send those files as an attachment

We have these files in say \home\abcd\dm Summary.txt log_SI-100.lst log_SI-101.lst log_SI-106.lst The contents of Summary.txt is as below ./log_SI-100.lst:Error detected, rollbacking ./log_SI-101.lst:Error detected, rollbacking ./log_SI-106.lst:Error detected, rollbacking Now i... (5 Replies)
Discussion started by: depakjan
5 Replies

8. Shell Programming and Scripting

Join two files values duplciating first file

Hi all, I am tryin to join two files, duplicating the alues from the first one as many times as the second. File one : 11 211 File two: a b c Result: 11 211 a 11 211 b 11 211 c Any advise will be apreciate. Thanks (3 Replies)
Discussion started by: valigula
3 Replies

9. Shell Programming and Scripting

Searching data files for another file of values

I've used awk for some simple scripting, but having trouble figuring out how to search a couple of data files that have Name/Address/Zip Codes from another file that has list of only Zip Codes, and write out the lines that matched. Zip code field in the data file is 27 I was thinking... (5 Replies)
Discussion started by: matkins99
5 Replies
Login or Register to Ask a Question