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:
You need to apt-get install python-sqlparse. This command simply formats a sql query and prints it out. It is very useful when you want to move a sql query from commandline to a shell script. Everything is done locally, so you don't need to worry about copying sql query to external websites.
They are using json now
Good because it doesn't use Sed.
For situations where you keep JSON in a VCS and you want your diffs to be sane, such as within a Chef configuration repo.
Convert JSON to YAML.
Note that you'll need to have PyYaml installed.
Converts YAML file to JSON.
Note that you'll need to install PyYAML. Also some YAML data types (like dates) are not supported by JSON).
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.
you need ruby gems and localtunnel, further instruction on their website
for ubuntu precise, just intall ...
sudo apt-get install ruby ruby1.8-dev rubygems1.8 libopenssl-ruby
sudo gem install localtunnel
ssh-keygen -t rsa
python -m SimpleHTTPServer 8000
sudo localtunnel -k ~/.ssh/id_rsa.pub 8000
(1) required: python-googl ( install by: pip install python-googl )
(2) get from google API console https://code.google.com/apis/console/
Realtime lines per second in a log file using python ... identical to perl version, except python is much better :)
useful if you are using lots of data URI's in your css files
Very useful for test a script. After launch this command, you only have to press ENTER for launch your script again. I work with screen and tape ENTER instead of '!!'+ENTER
If you break your script with CTRL-C, it will wait for press ENTER and will re-launch
You can write like it : while read -p "Press ENTER" ; do python ; done
You can use "decode()" in a similar manner:
python -c 'print "68656c6c6f".decode("hex")'
Python is always such much more readable than most shell scripting.
Remove dashes, also validates if it's a valid UUID (in contrast to simple string-replacement)
This opens a python command line. You can use math and random and float-division is enabled (without appending .0 to integers). I just don't know how to specify a standard precision.
ZenCart uses a MD5 with a salt to secure its passwords. If you need to forcibly change someone's password to a known value within the database, this one-liner can generate the password. Change the value of 'p' to the password you want.
A common programming question for interviewers to ask potential job candidates is to code "FizzBuzz". That is, if a number is divisible by 3, then it should display "Fizz". If a number is divisible by 5, it should display "Buzz". If it is divisible by both, then it should display "FizzBuzz". Otherwise, display the current number between 1 and 100.
This works on all versions of python 2.X.
Tested on Linux and bundled python versions on Mac OSX and Solaris / UNIX
Note: Serves globally on port 8000.
Ctrl+c to stop.
Don't start the server and leave it on a internet connected machine. :)