Write a Bash Script that takes a directory name as a command line argument and clean the directory by removing all the files with a zero length, with a .tmp or with a .swp extension that is found in this directory. After, create an archive of this directory, compress the archive and place it in your ~directory?
#!/bin/bash
if [ -d $1 ]
then
find -empty -print -exec rm -f {} \;
find . -name "*.tmp" -print -exec rm -f {} \;
find . -name "*.swp" -print -exec rm -f {} \;
tar -zxvf $filename.tar.gz /~/ \;
else
echo "this file is not a directory"
fi
Im stuck on the archive part, can you guys give me some hints! thanks and have nice day.