banner

For a list of BASHing data 2 blog posts see the index page.    RSS


How to crunch a grawlix

A grawlix is a string of characters used to replace swear words in speech bubbles and other text.

cartoon

Cartoon by Threeboy, CC BY 2.0

The characters in grawlixes are typically chosen from 6 "space-filling" ones found near the top of your keyboard, namely ! @ # $ % &. A grawlix normally ends with ! or !? and there's no repetition of characters.

You could create a grawlix easily enough just by tapping at those top-of-keyboard keys with Shift depressed. However, since there are 5 non-! characters available, there are 120 possible 5-character strings (with no repetition) plus a ! for even a simple grawlix. How to get the full range of possibles?

A good method starts with the command-line utility crunch (available in the repositories). See man crunch for details on how to use the program, but the following command builds those 120 grawlixes and adds a final ! with sed:

crunch 5 5 -p \@\#\$\%\& | sed 's/$/!/' | column

crunch

crunch is told with "5 5" that you're aiming for strings with a minimum and a maximum of 5 characters. The -p option means no repetition of characters, and the 5 non-! characters are fed to crunch escaped.
 
crunch can also be used to generate passwords, but pwgen is friendlier.

To avoid getting the crunch messages use 2>/dev/null, and to select just one random grawlix from the 120, use shuf:

crunch 5 5 -p \@\#\$\%\& 2>/dev/null | sed 's/$/!/' | shuf -n1

shuf

Last update: 2024-08-02
The blog posts on this website are licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License