0

As the title says, what is the shortest way to remove the /boot folder after a random amount of time in Bash (or Zsh)?

The purpose of this is a tattoo, with similar length of this one, which is 19 characters long (or 20 with correct syntax) and 11 without the prompt.

Old tattoo: life:~# :(){:|:&};:

I've tried this so far, which is too many characters (42 without prompt):

life:~# if [ $RANDOM = 1 ]; then; rm -r /boot; fi
Community
  • 1
  • 1
spydon
  • 9,372
  • 6
  • 33
  • 63
  • 1
    The `[ $RANDOM = 1 ]` performs only a single test. That's only a 1 in 32767 chance of removing `/boot`. :) – dan4thewin Feb 18 '16 at 18:02

2 Answers2

2

A little shorter...

sleep $RANDOM;rm -r /boot

To be honest, the significance of removing boot is lost on me. A box can keep running without it. How about kill -9 1 instead?

dan4thewin
  • 1,134
  • 7
  • 10
  • The box will keep running, but you better not halt it. `#kill -9 1` might be his next tattoo ;) – Auzias Feb 18 '16 at 18:26
  • As you need to restart the box as an effect of the other tattoo you wont be able to start it again. :) – spydon Feb 18 '16 at 18:42
1

The if can conveniently be replaced with a short-circuit.

[ $RANDOM = 1 ] && rm -r /boot

This still performs only a single shot with a fairly low probability of actually doing anything.

You could somewhat more obscurely use arithmetic context, which evaluates to false (1) if the value of the calculation is zero.

(($RANDOM)) || rm -r /boot

Running this in a tight loop with while is obviously longer, and does not wait for very long before I get a zero (typically less than a second); you could add a sleep to delay it but this is already pretty long.

while (($RANDOM)) || { rm -r /boot; false; }; do : ; done

The pesky false and the braces is to get the loop to exit when the random number "finally" reaches zero.

tripleee
  • 175,061
  • 34
  • 275
  • 318
  • 1
    I guess the last one might be possible to do recursively to get down the number of characters a bit. – spydon Feb 18 '16 at 18:47