2.7 Control Flow - If
2.7 Control Flow - If
is equivalent to
for i do ... done
shift is a shell command that renames the positional parameters $2, $3, ... as $1, $2, ... and loses $1.
Another kind of use for the while/until loop is to wait until some external event occurs and then run some commands. In an until loop the termination condition is reversed. For example,
until test -f file do sleep 300; done commands
will loop until file exists. Each time round the loop it waits for 5 minutes before trying again. (Presumably another process will eventually create the file.)
that tests the value returned by the last simple command following if.
The if command may be used in conjunction with the test command to test for the existence of a file as in
if test -f file then process file else do something else fi
An example of the use of if, case and for constructions is given in section 2.10.
fi
The following example is the touch command which changes the `last modified' time for a list of files. The command may be used in conjunction with make (1) to force recompilation of a list of files.
flag= for i do case $i in -c) flag=N ;;