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
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.