Hi,
I have 2 sets of text files. I need to take a field from a certain line in set 1 and put it in the same place in set b. The line appears once per file, in different places but is a set format and has the unique word "ANTENNA" in it and is always 81 characters long. Example from set a:
" 0.0000 0.0000 0.0000 ANTENNA: DELTA H/E/N"
Example from set b
" 0.2160 0.0000 0.0000 ANTENNA: DELTA H/E/N"
The bold bit is the field I'm trying to change and will be a random float in both sets.
I've been trying to do it like this:
#!/bin/ksh
old_line=`grep ANTENNA ./file1.txt`
new_line=`grep ANTENNA ./file2.txt`
sed "s/${old_line}/${new_line}/" file1.txt >tmp2 #substitute old line with new line in file 1 and output to tmp2
But this doesn't work, probably because I have forward slashes in my grep lines which sed interprets as some sort of regexp. How can I escape these when they are embedded in a variable? Am I quoting incorectly? Or is there a much better way?
Jon