Difference between revisions of "User:Minooz/RepoSyncProj/Bash"
< User:Minooz | RepoSyncProj
(→Tips) |
(→Tips) |
||
Line 6: | Line 6: | ||
*Watch the spaces | *Watch the spaces | ||
<source lang=bash> | <source lang=bash> | ||
− | |||
if [ -d "$tmpInternal" ]; then | if [ -d "$tmpInternal" ]; then | ||
rm -r $tmpInternal >> $dateError.txt | rm -r $tmpInternal >> $dateError.txt | ||
Line 17: | Line 16: | ||
* The increment operator in bash | * The increment operator in bash | ||
<source lang=bash> | <source lang=bash> | ||
− | |||
while [ $revTmpInternal -lt $revInternal ]; do | while [ $revTmpInternal -lt $revInternal ]; do | ||
((revTmpInternal++)) | ((revTmpInternal++)) | ||
done | done | ||
+ | </source> | ||
+ | |||
+ | |||
+ | * 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") | ||
+ | <source lang=bash> | ||
+ | |||
+ | if [ -f "*.patch" ]; then | ||
+ | rm *.patch | ||
+ | fi | ||
</source> | </source> |
Revision as of 14:37, 18 October 2010
Bash Scripting Help
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