I have created a shell script to complete 3 simple tasks (zip a directory, rename the final file and delete the source directory). The script source is below:
#!/bin/bash
if [[ $2 == *"/data/"* ]]
then
src= $2"/*";
dest= $1".zip";
# Just for test
echo $src;
# Commented for now
#zip -r -j $dest $src
#mv $dest $1
#rm -rf $2
else
echo "Invalid arguments";
fi
When I run the script above with these parameters I have with error:
./scriptzip.sh /data/file-new /data/file-old
./scriptzip.sh: line 4: /data/file-old/*: No such file or directory
./scriptzip.sh: line 5: /data/file-new.zip: No such file or directory
How can prevent the shell to test a variable for "directory like" string? There is any way to skip that?