commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
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.
Returns last day of current month. Useful to implement a bash script backup based on a GFS strategy.