True and false (commands)
The commands are available in Unix-like operating systems. UseThe commands are usually employed in conditional statements and loops of shell scripts. For example, the following script repeatedly executes while true
do
echo hello
done
The commands can be used to ignore the success or failure of a sequence of other commands, as in the example: make … && false
Setting a user's login shell to false, in /etc/passwd, effectively denies them access to an interactive shell, but their account may still be valid for other services, such as FTP. (Although /sbin/nologin, if available, may be more fitting for this purpose, as it prints a notification before terminating the session.) The programs accept no command-line arguments except that the GNU version accepts the typical Null commandThe true command is sometimes substituted with the very similar null command,[1] written as a single colon ( while :
do
echo hello
done
The null command may take parameters, which are ignored. It is also used as a no-op dummy command for side-effects such as assigning default values to shell variables through the : ${TMPDIR:=/tmp}
: ${EDITOR=$DEFEDITOR}
: ${USER=${LOGNAME-`whoami`}}
See also
Notes
References
External linksThe Wikibook Guide to Unix has a page on the topic of: Commands
Manual pages |