UsiScript
loop for
Code
#For the THECONDITION, we do the command for (( c=1; c<=5; c++ )); do #put some code here or commands echo "$c" done
loop for all element in a array
Code
#For the objects in the array, we do the command array=( one two three ) for i in "${array[@]}" do #echo $i # COMMANDS done
loop browse files in a dir
Code
#We declare the folder name VARthefolder="THECONDITION" # We check if the folder exist if [ -d "$VARthefolder" ]; then #If the folder exist, we open it and brows it for folderitem in $VARthefolder/* do # put code/commands here echo $folderitem if [ "${folderitem}" == "/etc/resolv.conf" ] then echo "" break fi done else echo "The folder $VARthefolder doesn't exist" fi
loop for each object in a list
Code
#For all the objects (in the condition given), we do the command for i in THECONDITION ; do #put some code here or commands echo "" done
loop for each output results of a command
Code
#For the result (output) of the command ( = THECONDITION), we do the command for outputcmd in $(THECONDITION); do #put some code here or commands echo "$outputcmd" done
loop until
Code
#Until the THECONDITION, we do the command until [ THECONDITION ] do #put some code here or commands echo "" done
loop while
Code
# While the THECONDITION, we do the command while [ THECONDITION ] do #put some code here or commands echo "" done