I have the following task:
Write a program that, given a directory as argument, makes a tar file compressed with gzip and which name should be in the form "dirNameYYYY-MM-DD.tar.gz". If said file exists, it should return an error message.
What I tried:
#!/bin/bash
dir=$1
tarName=$dir`date '+%Y-%m-%d'`.tar.gz
if [ -e $tarName]
then
echo "That file already exists."
else
tar -cvz $HOME/$tarName '/'$dir *
fi
Why is this not working? Any suggestions on how I could fix it?
${dir}/*at the last line?