Does anyone know of a way to zip the resulting file from a find command?
My approach below finds the file and zips the entire directory path, which is not what I need.
After scanning the web, it seems to be much easier to perform gzip, but unfortunately the approach must use zip.
find `$DIR` -name 'CONTACTS_*.txt' -exec zip '{}'.zip '{}' \; -delete
While it does now zip by explicitly providing the directory path, when I unzip the file again as a check, I get ./path/to/directory/CONTACTS_1.txt. I should also mention that $DIR is in a different directory than from where the script is run.
If you are providing directory path then you can run script anywhere you want.
But if you are not providing path then you should run your script where you want to run.