I have two files:
file1.dat
1.01
2.01
3.01
4.01
5.01
5.02
6.01
7.01
8.01
9.01
And another file, file2.dat as follow:
0006.01
0008.01
What I want is to eliminate from the file1.dat the numbers listed in the file2.dat, to do that I made a bash script as follow:
#!/bin/bash
touch file1.dat
touch file2.dat
for f in $(< file2.dat)
do
sed "/$f/d" file1.dat > output.dat
done
But actually the result is that the output.dat is equal to file1.dat, thus I don't know if, maybe, the problem are the zeros in front of the numbers in the file2.dat.
Thanks to everybody.
[SOLVED]
The problem was due to the space/tab at the beginning of the file. I solve it with the followed bash:
1) I rewrite the file2.dat with a very small f90 code to eliminate the zeros in front of the reals,
2) I launch the script to eliminate from file1.dat the tab/spaces and then the awk command:
cat file1.dat | tr -d " \t\r" > file1_1.dat
cat file2_rewrit.dat | tr -d " \t\r" > file2_rewrit_1.dat
awk 'FNR==NR {a[$0];next} !($0 in a)' file2_rewrit_1.dat file1_1.dat > output.txt