Results 1 to 2 of 2
I'm having trouble understanding what the colon is used for in bash? Can somebody explain it to me with an example? thanks!...
- 01-11-2009 #1Just Joined!
- Join Date
- Jan 2009
- Posts
- 1
the meaning of builtin colon
I'm having trouble understanding what the colon is used for in bash? Can somebody explain it to me with an example? thanks!
- 01-11-2009 #2
Well first, from the bash man page:
Basically, : does nothing, and produces no output. So why is it useful? It allows us to do stuff like this:Code:: [arguments] No effect; the command does nothing beyond expanding arguments and performing any specified redirections. A zero exit code is returned.
Now, we can enable or disable debug statements just by changing the value of $DEBUG_DEFINED.Code:#!/bin/bash if [ $DEBUG_DEFINED ]; then DEBUG_COMMAND=echo else DEBUG_COMMAND=: fi DEBUG_COMMAND "This is a debug statement."
: is also useful for clearing files:
file still exists, but it has no content.Code:: > file
Does this make sense?DISTRO=Arch
Registered Linux User #388732


Reply With Quote