What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again.

Delete that bloated snippets file you've been using and share your personal repository with the world. 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.

If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/

Get involved!

You can sign-in using OpenID credentials, or register a traditional username and password.

First-time OpenID users will be automatically assigned a username which can be changed after signing in.

Universal configuration monitoring and system of record for IT.

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:



May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!

Top Tags





Commands using gcc from sorted by
Terminal - Commands using gcc - 17 results
gcc -dM -E - </dev/null
2013-09-30 15:08:34
User: slower
Functions: gcc
Tags: gcc

Lists all macros and their values defined by gcc.

vim test.c && gcc -x c -o a.out test.c && ./a.out && rm a.out test.c
f=220;echo "int s=16e3/$f;main(i){unsigned char v[s];read(0,v,s);for(;;)putchar(v[i%s]=(v[i%s]+v[++i%s])/2);}"|gcc -x c -&&./a.out</dev/urandom|aplay -d 2
2013-06-28 14:52:53
User: tehdog
Functions: aplay echo gcc
Tags: alsa sh gcc

outputs a f=220Hz guitar string sound (fifth string A)

needs ALSA

sudo apt-get install git gcc make libx11-dev libxtst-dev pkg-config -y && git clone https://github.com/hanschen/ksuperkey.git && cd ksuperkey && make && sudo mv ksuperkey /usr/bin/ksuperkey && cd ~ && rm -rf ksuperkey
2013-04-17 07:12:46
User: FadeMind
Functions: cd gcc install make mv rm sudo

Install Ksuperkey one command in Kubuntu.

You must manually add ksuperkey to autostart in System Settings KDE.

echo "main(i){for(i=0;;i++)putchar(((i*(i>>8|i>>9)&46&i>>8))^(i&i>>13|i>>6));}" | gcc -x c - && ./a.out | aplay
2013-02-17 21:31:04
User: SNDR
Functions: echo gcc
Tags: aplay

Try modifying the numbers in the "(i*(i>>8|i>>9)&46&i>>8))^(i&i>>13|i>>6)" part.

Crudely stolen from http://www.xkcdb.com/9067

echo "main(i){for(i=0;;i++)putchar(((i*(i>>8|i>>9)&46&i >>8))^(i&i>>13|i>>6));}" | gcc -x c - && ./a.out | aplay
2013-01-09 21:48:23
User: r0nd0n
Functions: echo gcc

Something I pulled off 4chan, it plays a tune.

gcc -E code.c | sed '/^\#/d' | indent -st -i2 > code-x.c
gcc -dM -E - < /dev/null
for c in gcc bison dialog bc asdf; do if ! which $c >/dev/null; then echo Required program $c is missing ; exit 1; fi; done
echo | gcc -dM -E -
alias cstdin='echo "Ctrl-D when done." && gcc -Wall -o ~/.stdin.exe ~/.stdin.c && ~/.stdin.exe'
2009-11-19 16:38:51
User: taliver
Functions: alias gcc

This is a quick hack to make a gcc caller. Since it runs with gcc instead of tcc, it's a bit more trustworthy as far as the final answers of things go.

gcc -dM -E - <<<''
gcc -dM -E - < /dev/null
gcc -x c -o /tmp/out - -lgmp <<< '#include <stdlib.h> ... SEE SAMPLE OUTPUT FOR FULL COMMAND
2009-09-10 02:10:46
User: hank
Functions: c++ gcc

It's hard to beat C. This is just slightly faster than the bc version on my machine.

real 0m26.856s

user 0m25.030s

sys 0m0.024s

Requirements: libgmp headers, gcc.

ls *.c | while read F; do gcc -Wall -o `echo $F | cut -d . -f 1 - ` $F; done
2009-08-28 13:01:56
User: pichinep
Functions: cut gcc ls read

Compile *.c files with "gcc -Wall" in actual directory, using as output file the file name without extension.

/lib/ld-linux.so.2 =(echo -e '#include <stdio.h>\nint main(){printf("c one liners\\n");}' | gcc -x c -o /dev/stdout -)
2009-02-20 06:06:29
User: mrtheplague
Functions: c++ echo gcc

is the runtime linker/loader for ELF binaries on Linux.

=(cmd) is a zsh trick to take the output for the command "inside" it and save it to a temporary file.

echo -e 'blah' | gcc -x c -o /dev/stdout -

pipes the C source to gcc. -x c tells gcc that it's compiling C (which is required if it's reading from a pipe). -o /dev/stdout - tells it to write the binary to standard output and read the source from standard input.

because of the the =() thing, the compiled output is stashed in a tempfile, which the loader then runs and executes, and the shell tosses the tempfile away immediately after running it.

gcc -Wall -Werror -o prog prog.c || rm -f prog.c