I have set up a sed expression that finds an old number in a file and replaces it with a new number. I have no problem with this.
I have many files. For each file, i, the new number needs to come from row i of a column of data in another file (let's called it "newNumbers"), like the example below.
1.2345 10.6789 100.101112 ...
- I can do this by doing (inside a for loop over file (i)):
i = 1 while read line do var[$i]="$line" find ... # My sed expression for finding and replacing a word in file (i). i=$((i+1)) done < newNumbers
However, this is not a good solution. "newNumbers" is so long that it will take days. I know the line I need from "newNumbers." It is line i, which corresponds to file i. So I want to read in the value from "newNumbers" at line i. I cannot get the syntax right to do this though (I am not experienced with bash). I'm using GNU sed on a Mac and have checked out several questions that seem related here. Examples that have resulted in "char1: missing command" or '"iq;d": command expects \ followed by text'-type errors are:
gsed -n -e "${i}" newNumbers
gsed 'iq;d' newNumbers
gsed "${i}q;d" newNumbers
I don't know if this is a Mac problem (GNU sed) or some syntax problem. Thank you for any help.