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.
» 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:
Schematics:
command [options] [paste your variable here] parameter
command [options] [paste entire column of variables here] parameter
...
(hard-code command "c" and parameter "e" according to your wishes: in example shown command = "cp -a" and parameter = "~")
Features:
- Quick exchange only variable part of a long command line
- Make variable part to be an entire column of data (i.e. file list)
- Full control while processing every single item
Hints:
Paste column of data from anywhere. I.e. utilize the Block Select Mode to drag, select and copy columns (In KDE Konsole with Ctrl+Alt pressed, or only Ctrl pressed in GNOME Terminal respectively).
Disadvantages:
You can paste only one single variable in a row. If there are more space separated variables in a row only first one will be processed, but you can arrange your variables in a column instead. To transpose rows to columns or vice versa look at Linux manual pages for 'cut' and 'paste'.
TODO:
- add edit mode to vary command "c" and parameter "e" on the fly
- add one edit mode more to handle every list item different
- add y/n/a (=All) instead of only y(=default)/n to allowed answers
Disclaimer:
The code is not optimized, only the basic idea is presented here. It's up to you to shorten code or extend the functionality.
Enhancement for the 'busy' command originally posted by busybee : less chars, no escape issue, and most important it exclude small files ( opening a 5 lines file isn't that persuasive I think ;) )
This makes an alias for a command named 'busy'. The 'busy' command opens a random file in /usr/include to a random line with vim.
In case sed and awk are not available you may use this to remove the last character from a string with "rev" and "cut".
Expand a URL, aka do a head request, and get the URL. Copy this value to clipboard.
Grabs the Apache config file (yielded from httpd) and returns the path specified as DocumentRoot.
Nothing special about hashing here, only the use of cut, I think, could result at fewer keystrokes.
list top committers (and number of their commits) of svn repository.
in this example it counts revisions of current directory.
displays current time in "binary clock" format
(loosely) inspired by: http://www.thinkgeek.com/homeoffice/lights/59e0/
"Decoding":
8421
.... - 1st hour digit: 0
*..* - 2nd hour digit: 9 (8+1)
.*.. - 1st minutes digit: 4
*..* - 2nd minutes digit: 9 (8+1)
Prompt-command version:
PROMPT_COMMAND='echo "10 i 2 o $(date +"%H%M"|cut -b 1,2,3,4 --output-delimiter=" ") f"|dc|tac|xargs printf "%04d\n"|tr "01" ".*"'
this will dump a list of domains one per line into a text file
Here's an awk alternative, for those lacking the version of cut with the --complement argument.
Show all columns except 5th. This might help you save some typing if you are trying to exclude some columns from the output.
Use this BASH trick to create a variable containing the TAB character and pass it as the argument to sort, join, cut and other commands which don't understand the \t notation.
sort -t $'\t' ...
join -t $'\t' ...
cut -d $'\t' ...
Most systems (at least my macbook) have system users defined, such as _www and using "users" for example will not list them. This command allows you to see who the 'virtual' users are on your system.