in linux you can use the evil bird emoticon (:>) to destroy files, eg `:> important_document.txt`
-
@rebane2001@infosec.exchange 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 a no-op with no output, which is then redirected to the file.
See: https://stackoverflow.com/questions/3224878/what-is-the-purpose-of-the-colon-gnu-bash-builtin -
@jcpandrade@mastodon.social ha! I tend to do
while truebecause 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@woem.men @rebane2001@infosec.exchange@dakkar I used the true but... : is faster and easier to type... Just being lazy, I admit. @ChaosKitsune @rebane2001
-
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!
@rebane2001 The nice bird is named sudo rm -rf / -
@rebane2001 it doesn't eat worms `~`

```
$
~
bash: /home/user: Is a directory
``` -
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!
@rebane2001 It's a cool fact
-
@rebane2001@infosec.exchange 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?':' returns 0 (meaning true). I just checked and '>' clears the file with no input. So, yes, the ':' is just decorative.
-
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!
@rebane2001 New "Press Alt+F4 to win" just dropped.
-
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!
Thanks! I’ve learned AND cemented
as evil bird -
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!
Very interesting. Never seen it in a long life of use of Unix.
Is there a "cheat sheet" of other unknown - at least by me
- such "wild" characters for file redirection ? -
Very interesting. Never seen it in a long life of use of Unix.
Is there a "cheat sheet" of other unknown - at least by me
- such "wild" characters for file redirection ?@tanavit > is pretty well known and : is a shell built-in similar to true, it's just the combination of the two that's uncommon
-
@tanavit > is pretty well known and : is a shell built-in similar to true, it's just the combination of the two that's uncommon
Thanks.
-
@rebane2001@infosec.exchange 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 it's a bash builtin
$ help :
:: :
Null command.No effect; the command does nothing.
Exit Status:
Always succeeds. -
@cenobyte @rebane2001 I usually just use
truncateorecho "" > whateverbut 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.
-
@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@infosec.exchange 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 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"
-
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!
@rebane2001 the everpresent word snatcher is real...

-
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!
@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
-
R relay@relay.infosec.exchange shared this topic