commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
Good for summing the numbers embedded in text - a food journal entry for example with calories listed per food where you want the total calories. Use this to monitor and keep a total on anything that ouputs numbers.
Print out list of all branches with last commit date to the branch, including relative time since commit and color coding.
Returns tomorrow's date in the format yyyyMMdd
Returns yesterday's date in the format yyyyMMdd
This command might not be useful for most of us, I just wanted to share it to show power of command line.
Download simple text version of novel David Copperfield from Poject Gutenberg and then generate a single column of words after which occurences of each word is counted by sort | uniq -c combination.
This command removes numbers and single characters from count. I'm sure you can write a shorter version.
There was another line that was dependent on having un-named screen sessions. This just wouldn't do. This one works no matter what the name is. A possible improvement would be removing the perl dependence, but that doesn't effect me.
When Ldapsearch queries an Active directory server, all the dates are shown using a timestamp of 18 digits. This perl regexp decodes them in a more human friendly notation. 11644473600 corresponds to some microsoft epoch.
This command will replace all instances of 'foo' with 'bar' in all files in the current working directory and any sub-directories.
Finds all directories containing more than 99MB of files, and prints them in human readable format. The directories sizes do not include their subdirectories, so it is very useful for finding any single directory with a lot of large files.
Running 'cpan Module::Name' will install that module from CPAN. This is a simple way of using a similar command to install a packaged Perl module from a Debian archive using apt-get.
recursively traverse the directory structure from . down, look for string "oldstring" in all files, and replace it with "newstring", wherever found
grep -rl oldstring . |xargs perl -pi~ -e 's/oldstring/newstring'
On command mode in Vim you can save parts of the current buffer in another file.
* The 'n' value represents the first line of the new file.
* The 'm' value represents the last line of the new file.
* newfile.txt is the newfile.
The results are similar to this command in perl:
perl -ne 'print if n..m' in.sql > out.sql