in linux you can use the evil bird emoticon (:>) to destroy files, eg `:> important_document.txt`
the bird will eat the file and leave it completely empty!
in linux you can use the evil bird emoticon (:>) to destroy files, eg `:> important_document.txt`
the bird will eat the file and leave it completely empty!
: (I mean yeah it does make the face but from a commands perspective I mean): is ignored or perhaps written into the file?@ChaosKitsune https://www.gnu.org/software/bash/manual/bash.html#index-_003a
the colon is a shell command that does nothing
it's often used to perform expansions with side-effects, like:
: ${ARGUMENT:=default value}
: ${MUST_BE_SET:?error message}@dakkar @ChaosKitsune @rebane2001 also infinite cycles:
while :
do
<whatever>
Done
while true because it reads better to me@dakkar @ChaosKitsune @rebane2001 @jcpandrade
I'd guess many shells execute true as built-in too.
true and false as builtins!@pacostegosaurus yep!:(){:|:&} is equivalent to:
function :() {
: | : &
}or, changing the name:function bomb() {
bomb | bomb &
}':' returns 0 (meaning true). I just checked and '>' clears the file with no input. So, yes, the ':' is just decorative.
@ChaosKitsune it's a bash builtin
$ help :
:: :
Null command.
No effect; the command does nothing.
Exit Status:
Always succeeds.
@ChaosKitsune @rebane2001 : is the null command in the POSIX shell standard. It's a built-in that outputs nothing and exits immediately with a status of zero (effectively the same as /bin/true).
So the shell parses ':> afile' as "null command with output redirected to afile"
truncate or echo "" > whatever but this is a lot more terse. I like it.@draeath @cenobyte @rebane2001
With echo "" you don't make an empty file though. It's a file with one octet (newline) then.
@rebane2001 it doesn't eat worms `~` β
```
$ :> ~
bash: /home/user: Is a directory
```
Thanks! Iβve learned AND cemented :> as evil bird