Open main menu

CDOT Wiki β

User:Minooz/RepoSyncProj/Bash

< User:Minooz‎ | RepoSyncProj
Revision as of 14:37, 18 October 2010 by Minooz (talk | contribs) (Tips)

Bash Scripting Help

Tutorial
Shell Programming
Linux org

Tips

  • Watch the spaces
if [ -d "$tmpInternal" ]; then
	rm -r $tmpInternal >> $dateError.txt 
elif [ -d "$tmpExternal" ]; then
	rm -r $tmExternal >> $dateError.txt 
fi


  • The increment operator in bash
while [ $revTmpInternal -lt $revInternal ]; do
	((revTmpInternal++))
done


  • to check if a file exists: (when using wild cards, if you don't use double quotes, there will be this error: "binary operator expected")
if [ -f "*.patch" ]; then
	rm *.patch
fi