Dear community,
I have one LOG directory with some files. What I need to do is list ONLY the files that are not present in other directory.
Using Bash programming!
LOG DIR | SYNC DIR
FILE1 | FILE1
FILE2 | FILE3
FILE3 | OTHER FILENAME
FILE4 |
FILE5 |
In this case there are 5 files under LOG directory and 3 files under SYNC directory, so the output list I'm expecting is
Please read what Corona688 has posted carefully. He didn't suggest globbing.
And if you need to use globbing to perform that operation on a select list of files from the directory, try a slight modification:
printf "%s\n" /log/*.DAT | while read FILE
do
[[ -e /log/sync/${FILE##*/} ]] || echo "$FILE"
done
Ah ok! You had modified the previous post and I don't see the code.
Now it working fine. BTW, I'm used asterisk because under LOG directory there is the SYNC directory, so I've to use * to take only .DAT files!
Just another question, if the file doesn't exists I need to show it and then copy to SYNC dir (so next time will not be shown). How can I add the copy command to the following line?