All commands (3)

  • The xorshift32 PRNG written by George Marsaglia in Bash, code golfed. Bash already has the $RANDOM and $SRANDOM environment variables, so this isn't all that useful. The seed "s" must be non-zero. Show Sample Output


    0
    n(){ s=$[s^s<<13];s=$[s^s>>17];s=$[s^s<<5];echo $[s&2**32-1]; }
    atoponce · 2026-07-31 03:42:35 0
  • Display a compact, columnized reference of printable ASCII characters and their shell-compatible octal escape sequences. Show Sample Output


    0
    for i in {1..256};do printf '%3d %b\n' $i \\0$((i/64*100+i%64/8*10+i%8));done|cat -t|column -c$((${COLUMNS:-80}/2))
    AskApache · 2026-08-13 07:42:31 0
  • Detects true graphical applications (Qt, GTK, SDL, FLTK, wxWidgets) by parsing ELF dynamic tags with readelf -d instead of relying on .desktop files or executing binaries. It ignores protocol-only CLI utilities (like xset or xrandr) by targeting widget toolkits directly rather than base display server libraries (like libX11 or libwayland-client).


    0
    for b in /usr/bin/*; do [[ -f "$b" && -x "$b" ]] && readelf -d "$b" 2>/dev/null | grep -qE 'libQt[0-9]?(Gui|Widgets)|libgtk-|libgdk-|libSDL|libforms|libfltk|libwx_' && echo "GUI: $b"; done
    wuseman1 · 2026-08-19 20:11:11 0

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands


Check These Out

Retry the previous command until it exits successfully
Repeat the previously used command (!!) until it exits with a success code (0). To put a delay between attempts you could do something like $ until !!; do sleep 5; done to wait 5 seconds after each attempt.

Kill XMMS for a cron job

When feeling down, this command helps
$ sudo apt-get install sl $ man sl

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

Print a row of characters the width of terminal
Unlike other methods that use pipes and exec software like tr or sed or subshells, this is an extremely fast way to print a line and will always be able to detect the terminal width or else defaults to 80. It uses bash builtins for printf and echo and works with printf that supports the non-POSIX `-v` option to store result to var instead of printing to stdout. Here it is in a function that lets you change the line character to use and the length with args, it also supports color escape sequences with the echo -e option. $ function L() { local l=; builtin printf -vl "%${2:-${COLUMNS:-`tput cols 2>&-||echo 80`}}s\n" && echo -e "${l// /${1:-=}}"; } With color: $ L "`tput setaf 3`=" 1. Use printf to store n space chars followed by a newline to an environment variable "l" where n is local environment variable from $COLUMNS if set, else it will use `tput cols` and if that fails it will default to 80. 2. If printf succeeds then echo `$l` that contains the chars, replacing all blank spaces with "-" (can be changed to anything you want). From: http://www.askapache.com/linux/bash_profile-functions-advanced-shell.html http://www.askapache.com/linux/bash-power-prompt.html

Git Global search and replace
Find all the occurrences in the git repo of 'foo' and replace with 'bar'

list files recursively by size

List all symbolic links in current directory
For those who don't have the symlinks command, you can use readlink. This command is not straightforward because readlink is very picky. The backslash in front of 'ls' means not to use an alias (e.g. color escape codes from an aliased 'ls' could mess up readlink), and the -1 (one) means to print the entries separated by newlines. xargs -l (the letter L) means to process each input separated by newlines as separate commands.

Convert CSV to JSON
Replace 'csv_file.csv' with your filename.

print code 3-up and syntax-highlighted for easy beach-time study
This is the setup I'm using for my largest project. It gives 357 lines per page (per side), which makes it fairly easy to carry around a significant amount of code on a few sheets of paper. Try it. (I stick to the 80 column convention in my coding. For wider code, you'll have to adjust this.)


Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: