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:
no external commands, but can only do 0-99, not 1-100, so we adjust it later
preferred way to query ps for a specific process name (not supported with all flavors of ps, but will work on just about any linux afaik)
http://en.wikipedia.org/wiki/Universally_Unique_Identifier
http://www.ossp.org/pkg/lib/uuid/
You'll first need to install the uuid package. Available immediately from apt in Ubuntu, Debian, or other myriad Debian variants. You could always compile it from source as well.
Best to put it in a file somewhere in your path. (I call the file spath)
#!/bin/bash
IFS=:; find $PATH | grep $1
Usage: $ spath php
watch is a command especially designed for doing this job
This command produces the output of "du -sk testfile" in every 10 seconds. You can change the command to be whatever you want.
I dont have curl or links installed, so I use wget with write file as standard out.
This regular expression removes all HTML-Tags from the file.
You can use that to create a excludefile for nmap, to find hosts, with no DHCP lease in your DHCP range.
Turns regular quotes into curly quotes, also converts hyphens to dashes using a heuristic and outputs the result as UTF-8, suitable to copy/paste into wordprocessor.
requires: http://daringfireball.net/projects/smartypants/ (which does most of the work)
(I renamed smartypants.pl to smartypants before adding it to my $PATH)
Also requrires PHP with the multibyte module installed (its installed by default with PHP, but the sysadmin on one server I use disabled it... presumadly to increase performance or something).
Lists ONLY the files changed by the given HASH/HEAD/list of hashes, etc. The message, commit ID, author, etc. is not included
This lengthy cryptic line will print the latest top 10 commandlinefu.com posts without their summaries. To print also their respective summaries use the following (even bigger) command line:
wget -qO - http://www.commandlinefu.com/feed/tenup | xmlstarlet sel -T -t -o '<doc>' -n -t -m rss/channel/item -o '<item>' -n -o '<title>' -v title -o '</title>' -n -o '<description>' -v description -o '</description>' -n -o '</item>' -n -t -o '</doc>' | xmlstarlet sel -T -t -m doc/item -v description/code -n -v title -n -n
It is recommended to include this line into a shell script to be easily run, as I do myself. You could also use the following URLs to browse the top 3 commands:
wget -qO - http://www.commandlinefu.com/feed/threeup | xmlstarlet ...
.. or all others:
wget -qO - http://feeds2.feedburner.com/Command-line-fu | xmlstarlet ...
PS: You need to install "xmlstarlet" to run it. It is found in Debian APT repositories (apt-get install xmlstarlet) or under the http://xmlstar.sourceforge.net/ URL.
translate and number lines is simpler and you use tr to choose your delimiter (eg for csv files)
The original doesn't work for me - but this does. I'm guessing that Youtube updated the video page so the original doesn't work.
A lot of X applications accept --geometry parameter so that you can set application size and position. But how can you figure out the exact arguments for --geometry? Launch an application, resize and reposition its window as needed, then launch xwininfo in a terminal an click on the application window. You will see some useful window info including its geometry.
When you have one of those (log)files that only has epoch for time (since no one will ever look at them as a date) this is a way to get the human readable date/time and do further inspection.
Mostly perl-fu :-/
This command will find the biggest files recursively under a certain directory, no matter if they are too many. If you try the regular commands ("find -type f -exec ls -laSr {} +" or "find -type f -print0 | xargs -0 ls -laSr") the sorting won't be correct because of command line arguments limit.
This command won't use command line arguments to sort the files and will display the sorted list correctly.
Very useful if you keep switching between the same two branches all the time.
As an alternative to using an additional grep -v grep you can use a simple regular expression in the search pattern (first letter is something out of the single letter list ;-)) to drop the grep command itself.