- To check if the file already exists on the filesystem
[ -f filename ] && echo"file exists" - To check if the directory exists on the filesystem
[ -f dirname ] && echo"dir exists" - To copy the output of the command executed in the script to a variable.
result=`pwd` exportcommand is used to set a environment variable.- Use = for comparisons not ==.
if [ $name = "shiv" ];
then
echo "its me"
fi - Use option "o" with unzip command to overwrite existing files without prompting.
unzip -o myArchive.zip - Use option "r" to travel recurcively with zip command
zip -r zipfilename sourcedir *
Following link points to a quick shell scripting reference.
http://www.opengroup.org/onlinepubs/007908799/xcu/shellix.html
No comments:
Post a Comment