comm -13 tmpfile tmpfile2 | grep -v <filename> >newfile
so i want to
- find records in 1 file bot not in another
- The output of the first part is 1 field in a file with many fields.
- find all the records that do not have the value piped from step #1
- redirect to a new file
when I do this, grep is expecting a file name and not a search value.
So you want grep to read expressions from the pipe, not data? I think you'll need a temporary file. Then you can feed grep the list of expressions via -f.
comm -13 tmpfile tmpfile2 > /tmp/$$
grep -f /tmp/$$ filename > newfile
rm -f /tmp/$$
If you want them to be considered fixed strings, not regexes, you can put an -F before the -f too.
Combined:
comm -13 tmpfile tmpfile2 | grep -vf- filename > newfile
1 Like
thanks, but I don't quite follow the syntax
comm -13 tmpfile tmpfile2 | grep -vf- filename > newfile
-vf-
what is vf?
why do you have a '-' after the f? I have never seen that in unix before with any function.
---------- Post updated at 10:16 AM ---------- Previous update was at 10:07 AM ----------
corona,
can i do this with a pipe with awk or sed or something else? so i dont create files? I can create them, just trying to figure out better ways to do things.
It could also be written as grep -v -f -
. "-" is a placeholder for stdin. It does not work with functions, but it works with many utilities.