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!

aah i shouldve called it the mischievous bird not evil!!
@rebane2001 hmm I suppose thats because its writing nothing into the file but I dont understand the reason for the : (I mean yeah it does make the face but from a commands perspective I mean)

Id assume it works without?

Im guessing
: is ignored or perhaps written into the file?
@ChaosKitsune @rebane2001 : is the no-op built-in in POSIX shells.
@lambda @ChaosKitsune @rebane2001 does that like actually run the no-op in assembly//machine level ?? or actually do nothing and return 0 ??
@pinkRhododendron @ChaosKitsune @rebane2001 the latter, there's no reason the *implementation* of the shell built-in would have to use an extra machine instruction that does nothing (though maybe the compiler sneakily inserts one anyway, e.g. for alignment reasons!)

@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}

@rebane2001

Bash Reference Manual

Bash Reference Manual

@dakkar @ChaosKitsune @rebane2001 also infinite cycles:

while :
do
<whatever>
Done

@jcpandrade ha! I tend to do while true because it reads better to me
(yes, I know that involves a fork+exec, but if we cared about speed we wouldn't be writing shell)
@ChaosKitsune @rebane2001
@dakkar I used the true but... : is faster and easier to type... Just being lazy, I admit. @ChaosKitsune @rebane2001

@dakkar @ChaosKitsune @rebane2001 @jcpandrade

I'd guess many shells execute true as built-in too.

@project1enigma oh, you're right (I hadn't noticed), bash has indeed true and false as builtins!
@ChaosKitsune @rebane2001 @jcpandrade
@dakkar @ChaosKitsune @rebane2001 so the classic fork bomb is redefining the : command?

@pacostegosaurus yep!
:(){:|:&} is equivalent to:

function :() { : | : & }or, changing the name:function bomb() { bomb | bomb & }
which calls itself twice (piping the non-exsitend output of the first call to the second) as a background process, therefore doubling the number of running processes every time (each process exits immediately, but it still bogs down the machine)

@ChaosKitsune @rebane2001

@dakkar @ChaosKitsune @rebane2001 Nice! I remember reading about this some time ago but somehow I missed that : was not only a valid identifier but actually a standard command
What is the purpose of the : (colon) GNU Bash builtin?

What is the purpose of a command that does nothing, being little more than a comment leader, but is actually a shell builtin in and of itself? It's slower than inserting a comment into your scripts...

Stack Overflow

@ChaosKitsune @rebane2001

':' 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.

@rebane2001

@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"

@rebane2001 It works 🀯
@pinkRhododendron @rebane2001
I would have also created an alias for the hungry cat to echo out on console
Burp, mjao
@rebane2001 I feed my evil bird junk files twice a day so they don't get hungry and start eating files I need
@rebane2001 thanks i was hungry :>
@rebane2001 This is awesome for clearing out files. Some log files when you're trying to isolate. Love learning new commands. Thank you!
@cenobyte @rebane2001 I usually just use 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.

@project1enigma @cenobyte @rebane2001 true unless you pass the argument not to add that... But at that point things are getting silly and there's definitely better ways. But in most of the things I work with, a truly empty file and a file with only a newline in it are close enough to equivalent.

@rebane2001 it doesn't eat worms `~` ❓

```
$ :> ~
bash: /home/user: Is a directory
```

@rebane2001 @astraluma

Thanks! I’ve learned AND cemented :> as evil bird

@rebane2001 the everpresent word snatcher is real...
@rebane2001 i would draw this if i had the energy to do so and also the art skills to draw that well enough to not have my perfectionist brain tear into me
@rebane2001 technically, it will only steal your file, not destroy it. Which, I guess, means that :> is a corvid.