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.
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:
Wow, didn't really expect you to read this far down. The latest iteration of the site is in open beta. It's a gentle open beta-- not in prime-time just yet. It's being hosted over at UpGuard (link) and you are more than welcome to give it a shot. Couple things:
Find files that are older than x days in the working directory and list them. This will recurse all the sub-directories inside the working directory.
By changing the value for -mtime, you can adjust the time and by replacing the ls command with, say, rm, you can remove those files if you wish to.
Note that the file at the given path will have the contents of the (still) deleted file, but it is a new file with a new node number; in other words, this restores the data, but it does not actually "undelete" the old file.
I posted a function declaration encapsulating this functionality to http://www.reddit.com/r/programming/comments/7yx6f/how_to_undelete_any_open_deleted_file_in_linux/c07sqwe (please excuse the crap formatting).
This runs a command continuously, restarting it if it exits. Sort of a poor man's daemontools. Useful for running servers from the command line instead of inittab.
An easy way to create aliases for moving between many directories
Long before tabbed terminals existed, people have been using Gnu screen to open many shells in a single text terminal. Combined with ssh, it gives you the ability to have many open shells with a single remote connection using the above options. If you detach with "Ctrl-a d" or if the ssh session is accidentally terminated, all processes running in your remote shells remain undisturbed, ready for you to reconnect. Other useful screen commands are "Ctrl-a c" (open new shell) and "Ctrl-a a" (alternate between shells). Read this quick reference for more screen commands: http://aperiodic.net/screen/quick_reference
I often need to add a timestamp to a file, but I never seem to remember the exact format string that has to be passed to the date command to get a compact datetime string like 20090220T231410 (i.e yyyymmddThhmmss, the ISO 8601 format popular outside the US)
mplayer -vo caca will give you a similar result but in color
instead of writing:
if [[ "$1" == "$2" ]]; then
echo "$1 is equal $2"
echo "$1 differs from $2"
[[ "$1" == "$2" ]] && echo "$1 is equal $2" || echo "$1 differs from $2"
This finds a process id by name, but without the extra grep that you usually see. Remember, awk can grep too!
search file for string1 or string2
Pump up the chatter, run this script on a regular basis to listen to your twitter timeline.
This is a rough first cut using several cli clips I have spotted around. There is no facility to not read those things already read to you. This could also easily be put in a loop for timed onslaught from the chatterverse, though I think it might violate several pointsof the Geneva Convention
UPDATE - added a loop, only reads the first 6 twits, and does this every 5 mins.
Very entertaining when run on someone elses machine remotely ;)