I've got the code below. It does it's job but it's scrappy. Can someone explain why grep -v -f doesn't work against an empty file?
Basically I have a file of presumed good data - I want to remove any by comparing with a file I know are bad. When the bad file is empty - the output file is also empty. It's weird.
Works fine when the bad file has some data - so you'll see the cheap hack fix I've put in.
if [ -s tmp.merge.nos ]
then
join -t, -v 1 tmp.both tmp.req.merges | sed 's/=/,/' | grep -v -f tmp.merge.nos > $infile.ready
else
join -t, -v 1 tmp.both tmp.req.merges | sed 's/=/,/' > $infile.ready
fi
Maybe comm would be better - but I'd like to know why it doesn't work anyway (grep -v -f). Cheers
