With this command you can use shell variables inside sed scripts. This is useful if the script MUST remain in an external file, otherwise you can simply use an inline -e argument to sed.
Reverse DNS lookups, from a file with list of IP's, here the file is called lookups.txt
Uses curl to download page of membership of US Congress. Use sed to strip HTML then perl to print a line starting with two tabs (a line with a representative) Show Sample Output
Print out contents of file with line numbers. This version will print a number for every line, and separates the numbering from the line with a tab. Show Sample Output
You WILL have problems if the files have the same name.
Use cases: consolidate music library and unify photos (especially if your camera separates images by dates).
After running the command and verifying if there was no name issues, you can use
ls -d */ | sed -e 's/^/\"/g' -e 's/$/\"/g' | xargs rm -r
to remove now empty subdirectories.
The shell has perfectly adequate pattern matching for simple expressions. Show Sample Output
The thunderbird message datastores get corrupt some times causing random failures, compaction to fail and general suck in thunderbird. Removing them causes thunderbird to rebuild the indexes and makes things quick again.
Substitute that 724349691704 with an UPC of a CD you have at hand, and (hopefully) this oneliner should return the $Artist - $Title, querying discogs.com. Yes, I know, all that head/tail/grep crap can be improved with a single sed command, feel free to send "patches" :D Enjoy! Show Sample Output
Deletes capistrano-style release directories (except that there are dashes between the YYYY-MM-DD) Show Sample Output
urldecode files in current directrory
chrome only lets you export in html format, with a lot of table junk, this command will just export the titles of the links and the links without all that extra junk Show Sample Output
Outputs the real time it takes a Redis ping to run in thousands of a second without any proceeding 0's. Useful for logging or scripted action.
Get info directly from /proc/uptime
d --> delete !d ---> delete others
Perl version - just for completeness sake ;)
This command is useful when you are programming, for example.
If you work in an environment, where some ssh hosts change regularly this might be handy...
Use it with cat and '|' for know what is used in a conf file. For example cat /etc/squid/squid.conf | sed -re '/^#/d ; s/#.*$// ; /^\s$/d' : Show you what you use in your file conf. It removes all comments and empty lines. Empty lines are lines with nothing, a tab, or a space.
This permit to convert an UNIX file to DOS file. You can use it in a loop to convert multiple files, like : for i in *.bat; do sed -i 's/$/\r/' $i; done
commandlinefu.com is the place to record those command-line gems that you return to again and again. 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.
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: