awk read value from file and paste in other file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk read value from file and paste in other file
# 8  
Old 04-17-2012
Unfortunately, your code isn't working for me.

You could please explain the commands?
Does FILENAME refer to value file?
Should it be written with quotes?

Thanks again
# 9  
Old 04-17-2012
Try:

Code:
while read nr val ; do 
  sed -i.bak "s/^replace$/$val/" "test$nr"
done < infile

$val should not contain forward slashes...
# 10  
Old 04-18-2012
I can not use "read" because in my value.file there are a lot of lines between the lines i want to read out:

114 1.2
.
.
233 2.8
.
.
665 1.4
....

Are there other ways?
# 11  
Old 04-18-2012
Use a case statement to weed out the unwanted lines
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Use while loop to read file and use ${file} for both filename input into awk and as string to print

I have files named with different prefixes. From each I want to extract the first line containing a specific string, and then print that line along with the prefix. I've tried to do this with a while loop, but instead of printing the prefix I print the first line of the file twice. Files:... (3 Replies)
Discussion started by: pathunkathunk
3 Replies

2. Shell Programming and Scripting

How to cut a pipe delimited file and paste it with another file to form a comma separated outputfile

Hello ppl I have a requirement to split (cut in unix) a file (A.txt) which is a pipe delimited file into A1.txt and A2.txt Now I have to join (paste in unix) this A2.txt with external file A3.txt to form output file A4.txt which should be CSV (comma separated file) so that third party can... (25 Replies)
Discussion started by: etldev
25 Replies

3. Shell Programming and Scripting

Using awk to read one file and search in another file

Hi Forum. I did some google search on what I'm trying to do but I cannot get my code to work correctly. I have 2 files which are very large and I want to read text from file1 and search in file2 - if present, keep the records. I've tried fgrep -f file1 file2 but it is too slow. File1:... (10 Replies)
Discussion started by: pchang
10 Replies

4. Shell Programming and Scripting

Help required the cut the whole contents from one file and paste it into new file

Hi, First of all sincere apologies if I have posted in a wrong section ! Please correct me if I am wrong ! I am very new to UNIX scripting. Currently my problem is that I have a code file at the location /home/usr/workarea/GeneratedLogs.log :- Code :- (Feb 7, 571 7:07:29 AM),... (4 Replies)
Discussion started by: acidburn_007
4 Replies

5. Shell Programming and Scripting

Paste content of a file to another file and make it as columned

Pls help me on this. I have to 2 files like shown below: File 1 TAIJM AXPKIM BEMGW File 2 PXMPA JYGE IMJP What i want to do is to paste both file to a new file on thir format: File 3 TAIJM PXMPA AXPKIM JYGE BEMGW IMJP I tried cat and print, but it doesn't work. Cn... (6 Replies)
Discussion started by: kingpeejay
6 Replies

6. Shell Programming and Scripting

Read a file and search a value in another file create third file using AWK

Hi, I have two files with the format shown below. I need to read first field(value before comma) from file 1 and search for a record in file 2 that has the same value in the field "KEY=" and write the complete record of file 2 with corresponding field 2 of the first file in to result file. ... (11 Replies)
Discussion started by: King Kalyan
11 Replies

7. Shell Programming and Scripting

read file column and paste it in command

Hi Unix gurus I have a file containing 2 coloumns. I would like to do a script which reads the lines and executes a command like this: command <field1> parameters <field2> some more parameters Please let me know how you would do this without AWK, SED or any other mini language (for special... (5 Replies)
Discussion started by: BearCheese
5 Replies

8. Shell Programming and Scripting

Need help with awk - how to read a content of a file from every file from file list

Hi Experts. I need to list the file and the filename comes from the file ListOfFile.txt. Basicly I have a filename "ListOfFile.txt" and it contain Example of ListOfFile.txt /home/Dave/Program/Tran1.P /home/Dave/Program/Tran2.P /home/Dave/Program/Tran3.P /home/Dave/Program/Tran4.P... (7 Replies)
Discussion started by: tanit
7 Replies

9. Shell Programming and Scripting

File Read using awk

Hi, I need to read two colums(4th and 5th) from a file and do some manipulation Input file is 401500 IOC Q 14 14 406200 LC Q 1 1 410124 IOC Q 5 4 410124 LC Q 11 8 410132 IOC Q 230 229 410148 IOC Q ... (3 Replies)
Discussion started by: rejirajraghav
3 Replies

10. Shell Programming and Scripting

Help with awk - read from file

Hi, I've got a file like the following: Starting to process segment 0 (and symmetry related segments) Number of (cancelled) singularities: 0 Number of (cancelled) negative numerators: 0 Segment 0: 5.49secs Starting to process segment 1 (and symmetry related segments) Number of... (7 Replies)
Discussion started by: giorgos193
7 Replies
Login or Register to Ask a Question