I need help! I am trying to use sed in a for loop and does not seem to be working correctly.
If I have a file called file2 that contains:
Field: LOAN_DATE
and I do:
i="loan_date"
sed -i "s/${i}/${i}/I" file2
This works replacing LOAN_DATE with loan_date
The problem is when I put this in a for loop it doen't work. I need it to loop on the file called file1 that contains multiple entries for compare and replace. File Examples:
file1 contains:
Field: loan_date
Field: Contact_no
Field: loan_NO
Field: acctount_no
file2 contains;
Field: LOAN_DATE
Field: CONTACT_NO
Field: LOAN_NO
Field: ACCOUNT_NO
My scritp is:
for i in `cat file1 |awk '{if $1 == "Field:") print $2}'`
do
sed -i "s/${i}/${i}/I" file2
done
Setting sed up to replace in file ignoring case. I get no change to the file.
Thanks for any help.
If I have a file called file2 that contains:
Field: LOAN_DATE
and I do:
i="loan_date"
sed -i "s/${i}/${i}/I" file2
This works replacing LOAN_DATE with loan_date
The problem is when I put this in a for loop it doen't work. I need it to loop on the file called file1 that contains multiple entries for compare and replace. File Examples:
file1 contains:
Field: loan_date
Field: Contact_no
Field: loan_NO
Field: acctount_no
file2 contains;
Field: LOAN_DATE
Field: CONTACT_NO
Field: LOAN_NO
Field: ACCOUNT_NO
My scritp is:
for i in `cat file1 |awk '{if $1 == "Field:") print $2}'`
do
sed -i "s/${i}/${i}/I" file2
done
Setting sed up to replace in file ignoring case. I get no change to the file.
Thanks for any help.