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.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
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:
Works even with spaces in filenames.
As an alias in .gitconfig:
[alias]
editchanged = "!git status --porcelain | sed -ne 's/^ M //p' | tr '\\n' '\\0' | tr -d '\"' | xargs -0 vim"
For a given filesystem return the LUN ID. Command assumes 1:1 relationship between fs:lv:hdisk:lun which may not be the case in all environments.
You have an external USB drive or key.
Apply this command (using the file path of anything on your device) and it will simulate the unplug of this device.
If you just want the port, just type :
echo $(sudo lshw -businfo | grep -B 1 -m 1 $(df "/path/to/file" | tail -1 | awk '{print $1}' | cut -c 6-8) | head -n 1 | awk '{print $1}' | cut -c 5- | tr ":" "-")
Sort netflow packet capture by unique connections excluding source port.
Feel free to put this in your ~/.profile:
random(){ cat /dev/urandom | env LC_CTYPE=C tr -dc $1 | head -c $2; echo; }
Then use it to generate passwords:
random [:alnum:] 16
Or DNA sequences:
random ACGT 256
displays a list of all file extensions in current directory and how many files there are of each type of extension in ascending order (case insensitive)
This lists the number of ogg/mp3/wav/flac files in each subdirectory of the current directory. The output can be sorted by piping it into "sort -n".
Uses urandom and tr to generate a random password. Change the value of head -c## for the lenght of the password.
Opposite:
Convert an one-liner to script:
foo() { <one-liner> ; }
...
typeset -f foo
...
unset -f foo
I did not come up with this one myself, but found this somewhere else several months ago.
Usage: t2s 'How are you?'
Nice because it automatically names the mp3 file up to 15 characters
Modified (uses bash manip instead of tr)
t2s() { wget -q -U Mozilla -O $(cut -b 1-15
My first command :) I made this command to log public addresses of a virtual interface who connects random VPN servers around the world.
Took one of the samples, added capitalization and removes in between spaces.
The final "echo" is just for readability.
Cheers
Counts of messages by recipient, with frozen messages excluded.
Replace $USER with the username of the Reddit user in question. To get comment karma instead run...
curl -s http://www.reddit.com/user/$USER/about.json | tr "," "\n" | grep "comment_karma" | tr ": " "\n" | grep -E "[0-9]+" | sed s/"^"/"Comment Karma: "/
make usable on OSX with filenames containing spaces. note: will still break if filenames contain newlines... possible, but who does that?!
This line unbuffers the interactive output of rsync's --progress flag
creating a new line for every update.
This output can now be used within a script to make actions (or possibly piped into a GUI generator for a progress bar)
It will produce passwords with length of 20 printable characters within a reasonable time.
For shorter or longer passwords just change the 20 in bs=20 to something more convenient.
To create only alpha numeric passwords change [:print:] to [:alnum:]