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/
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.
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.
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:
There are many ways to do it on *nix. But on Windows, it's a bit convoluted.
I use the above command expression in a batch file to check if a process is running already before running it again. I use this is a batch file I created to switch between 2 different versions of PowerBuilder (PB). I wanted to make sure, one version of PB is not running, before letting the user to switch, hence this check. (replace notepad.exe with PB125.exe above).
/nh means no header, /fi means filter. We are filtering for Notepad.exe only above. Then, we take that and look for Notepad.exe using a FindStr command. It will still work, even if we don't have those 2 flags, but it makes finding the right program quicker.
&& and || are part of the conditional expressions see here: http://www.robvanderwoude.com/condexec.php. We use these to print for the IF...ELSE condition.
>nul is the equivalent of Unix /dev/null
Rest is self explanatory, I think.
Calculate the date of Sysadmin day (last Friday of July) of any given year
echo 1 > /proc/sys/sunrpc/nfs_debug && tail -f /var/log/messages
to debug NFS issues.
this function will give you a status webpage code using curl.
echoprint identify your song, then return artist, song name and album name(release) in a JSON. jq parse it and mp3info set the data in your mp3 file.
of course it depends on:
You need to set the environment variable
You can use it with find, but probably will bypass the 120 request/minute of developer account key. So, use a sleep to do it.
find -name \*.mp3 | while read $f; do eval echo $(echoprint-codegen "$f" | jq ' ..metadata | "mp3info -a \"" + .artist + "\" -t \"" + .title + "\" -l \"" + .release + "\" \"" + .filename + "\"" ' ) | bash; sleep 1; done
Downloads a CRL file, determines the expiration time, and checks when it will expire
Change the scale to adjust number of decimal places
prefix the command with "time" to benchmark the computer (compare how long it takes to calculate 10000 digits of pi on various computers).
change the path where you are, when is executed, is usefule when you've got folders to classify something like a tags, you've got devel/dist, android/ios, etc. like:
You can change between devel/project folder to dist/project without leave project.
If somebody has a better idea to do that without replace command.
piped this to pbcopy (OSX only) you got a uuid in the pasteboard
bash brace expansion, sequence expression
Downloads this raw script https://github.com/git/git/blob/master/contrib/completion/git-completion.bash from Github, copies it to your home directory, autoloads it in ~/.bashrc and sources it.
just set macdst to the mac address of the system
you wish to wake up, the macsrc is optional but helps
use tcpreplay to broadcast or wireshark to view
Tested on Windows 8 w/SSH, Cygwin - it can be tricky to quote if you dont use the $(..) syntax to echo it back out
btrfs checksum errors console report.
Not better, but more lightweight (sed instead of perl).
Above command is reduced due to length restriction of less than 256 characters and entity encoding of "Save" command on this page. This is complete command (best without entity encoding):
echo -e '\x2Helo folks\t!\r' | sed "y/\x0\x1\x2\x3\x4\x5\x6\x7\x8\x9\xA\xB\xC\xD\xE\xF\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20/␀␁␂␃␄␅␆␇␈␉␊␋␌␍␎␏␐␑␒␓␔␕␖␗␘␙␚␛␜␝␞␟␠/"
Using the $PIPESTATUS array you can get the results of a command in a sequence of commands piped together. The command above returns the result of grep -o "bob", which is exit result of 1 since no match was made.
Mac OSX friendly version of google function