The idea behind this code is to find all files within a directory larger than 1KB (or 1000 bytes), compress them, and delete them from the original directory. I was able to figure out both of the separate commands but am unsure how to link the output from the first to the second commands (if that makes sense)? Can anyone point me in the right direction?
# Initialize variables
dir=~/Test
# Change directory to $DIRECTORY
cd "$dir"
# Find all files in the current directory that are larger than 1000 bytes (1KB).
find . -maxdepth 1 -type f -size +1000c | zip -mT backup
Use the -exec
option instead of trying to pipe the next command:
find . -maxdepth 1 -type f -size +1000c -exec zip -mT backup {} \;
Would create a zip
archive containing the matched files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With