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.
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:
Wow, didn't really expect you to read this far down. The latest iteration of the site is in open beta. It's a gentle open beta-- not in prime-time just yet. It's being hosted over at UpGuard (link) and you are more than welcome to give it a shot. Couple things:
Remove empty lines additionally:
tr -s ' \t\n' <1.txt >2.txt
tr -s '[:space:]' <1.txt >2.txt
To "clean perfectly" a text or code file, You can combine this command with
while read l; do echo -e "$l"; done <1.txt >2.txt
(= remove all leading and trailing spaces or tabs from all lines of a text file)
Not always does Xorg run on :0. For times like those, this script allows you to find out which it is.
tr has some predefined sets of characters that are more convenient to use than characters codes
Generate a 18 character password from character set a-zA-Z0-9 from /dev/urandom, pipe the output to Python which prints the password on standard out and in crypt sha512 form.
This command will encode a string using the ROT47 cipher.
Lauching an app including jars in an adjacent lib folder to its classpath
/dev/urandom is cryptographically secure, and indistinguishable from true random, as it gathers data from external sources, influenced by human timing interactions with computers, to fill the entropy pool, and hashes the input with SHA-1. As such, this is a quick way to do a "true random" fair-6 dice roll. Using this method, you could easily create passphrases with Diceware http://diceware.com.
Change the head(1) count to something other than 5 for more or less numbers.
Also shows files as they are found. Only works from a tty.
Copying and pasting from Office documents open in Office:mac can dirty your files with Windows CRLF and (inexplicably) Classic Mac OS LF newlines, which can break some tools. This snippet replaces them with good ol' Unix LF newlines.
If there are spaces won't work.
Convert long list of ' ' to a single space. Compress space and other characters.
Translates first set into second set
All files in the directory will be renamed replacing every space in the filename by "_" (underline) and converting upper case characters to lower case characters.
e.g. Foo Bar.txt --> foo_bar.txt
Use tput cols to find the width of the terminal and set it as the minimum field width.
dd can be used with /dev/zero to easily create a file of all zero-bytes. Pipe that through tr and use octal conversions to change the byte values from zero to 0xff (octal 0377). You can replace 0377 with the byte of your choice. You can also use \\0 and \\377 instead of the quoted version.