Hello all,
I have two files
file orig.txt(bigger one, almost 7000 lines):
Code:
12345 $secondfield $thirdfield $nfield SDFFF
23456 $secondfield $thirdfield $nfield DFEDFRGFF
34567 8090988 33435 655646 SFFEFEFKKLKL
90783 5433543 54532543 5454 HJHJHGGH
76576 435345 534 5453566767 WEQRTQ
and so on ....
file repl.txt(smaller one, 1000 lines):
Code:
34567 1111 3354 566 SFFEFEFKKLKL
90783 324324 255 54435 HJHJHGGH
76576 3232 4545 4554 WEQRTQ
field names(for avoiding confusions) as ordered example files :
USERNUMBER AMOUNT1 AMOUNT2 AMOUNT3 NAME
orig.txt contains all USERNUMBERs from repl.txt but AMOUNT[1-3]s are different .
I want to replace it line by line .
Can someone gave my an idea how to do that ?
First I try that
Code:
cat repl.txt | awk '{print $1}' > USERNUMBERS.txt
for i in $(awk '{print $1}' < USERNUMBERS.txt ) ; do grep -v $i orig.txt > removed_wrong_lines.txt ; done
I expected removed_wrong_lines.txt will contains only correct lines and after that simply do
Code:
cat removed_wrong_lines.txt repl.txt > corrected.txt
but my experiment was unsuccessful.
I will be thankful for any suggestions how to solve this.