I was just talking about the awk part. You still have to capture the output produced and copy it back to the target file. I just didn't understand why part of your code was using file and part of it was using file.txt .
You could either use:
grep -f input.txt -v file.txt > file
if you want what your script was doing, or you could use:
Don
both lines of code produce the fie but it is blank. i deleted a couple #'s in the input.txt file so that the file should have lines in it and just not blank .
When I copy and paste your samples into a file it works fine. When I remove one of the lines of input.txt , the corresponding line in file.txt gets printed. Could you try that yourself?
Also, make sure there are no empty lines in input.txt
Note that if you expect all lines in file.txt to be matched by a line in input.txt and you want file.txt to be an empty file in that case; change the command list to be:
You need to do this because the exit code from grep is 1 if no input lines are copied to the output file, but no errors occurred. (This is why file wasn't moved to file.txt when file was empty.)