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:
More recent versions of the date command finally have the ability to decode the unix epoch time into a human readable date. This function makes it simple to utilize this feature quickly.
extension to tali713's random fact generator. It takes the output & sends it to notify-osd. Display time is proportional to the lengh of the fact.
Though without infinite time and knowledge of how the site will be designed in the future this may stop working, it still will serve as a simple straight forward starting point.
This uses the observation that the only item marked as strong on the page is the single logical line that includes the italicized fact.
If future revisions of the page show failure, or intermittent failure, one may simply alter the above to read.
wget randomfunfacts.com -O - 2>/dev/null | tee lastfact | grep \<strong\> | sed "s;^.*<i>\(.*\)</i>.*$;\1;"
The file lastfact, can then be examined whenever the command fails.
While it seems (to me at least) a little counter-intuitive to filter on name first, this requires less work for find, as it allows it to immediately discount any files that do not match the name directly from the directory listing on disk. Querying against file attributes requires reading the file attributes, which is performed for all files matching any name based predicates.
Trickle is a voluntary, cooperative bandwidth shaper. it works entirely in userland and is very easy to use.
The most simple application is to limit the bandwidth usage of programs.
This is a handy way to circumvent the "Maximum line length of 2048 exceeded" grep error.
Once you have run the above command (or put it in your .bashrc), files can be searched using:
lgrep search-string /file/to/search
If you can install rpl it's simpler to use and faster than combinations of find, grep and sed.
See man rpl for various options.
time on above operation: real 0m0.862s, user 0m0.548s, sys 0m0.180s
using find + sed: real 0m3.546s, user 0m1.752s, sys 0m1.580s
A shell function using perl to easily convert Unix-time to text.
Put in in your ~/.bashrc or equivalent.
Tested on Linux / Solaris Bourne, bash and zsh. using perl 5.6 and higher.
(Does not require GNU date like some other commands)
adding users to groups on OS X is not a straightforward process, you need to use the new in built in Directory Service command line utility...
For Mac OS X users only
Sqlite database keeps collecting cruft as time passes, which can be cleaned by the 'vacuum;' command. This command cleans up the cruft in all sqlite files relating to the user you have logged in as. This command has to be run when firefox is not running, or it will exit displaying the pid of the firefox running.
Whereas ^V is CTRL-V.
converts a dos file to unix by removing 0x13 characters
This command displays a clock on your terminal which updates the time every second. Press Ctrl-C to exit.
A couple of variants:
A little bit bigger text:
watch -t -n1 "date +%T|figlet -f big"
You can try other figlet fonts, too.
Big sideways characters:
watch -n 1 -t '/usr/games/banner -w 30 $(date +%M:%S)'
This requires a particular version of banner and a 40-line terminal or you can adjust the width ("30" here).
See smbstatus Output within a 5 second interval (for monitoring smb access)
This is a working version, though probably clumsy, of the script submitted by felix001. This works on ubuntu and CygWin. This would be great as a bash function, defined in .bashrc. Additionally it would work as a script put in the path.
the middle command between the ; and ; is the vi commands that insert that line into the last line of the file, the esc with the carets is literally hitting the escape key, you have to have the smbfs package installed to do it, I use it to access my iTunes music on my mac from my linux PC's with amarok so I can play the music anywhere in the house. among other things, it allows you to access the files on that share from your computer anytime you're on that network.
Depending on the installation only certain of these man pages are installed. 12 is left out on purpose because ISO/IEC 8859-12 does not exist. To also access those manpages that are not installed use opera (or any other browser that supports all the character sets involved) to display online versions of the manpages hosted at kernel.org:
for i in $(seq 1 11) 13 14 15 16; do opera http://www.kernel.org/doc/man-pages/online/pages/man7/iso_8859-$i.7.html; done
Let me suggest using wget for obtaining the HTTP header only as the last resort because it generates considerable textual overhead. The first ellipsis of the sample output stands for
Spider mode enabled. Check if remote file exists.
--2009-03-31 20:42:46-- http://www.example.com/
Resolving www.example.com... 18.104.22.168
Connecting to www.example.com|22.214.171.124|:80... connected.
HTTP request sent, awaiting response...
and the second one looks for
Length: 438 [text/html]
Remote file exists and could contain further links,
but recursion is disabled -- not retrieving.