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:
I often use "vim -p" to open in tabs rather than buffers.
greps using only ascii, skipping the overhead of matching UTF chars.
$ export LANG=C; time grep -c Quit /var/log/mysqld.log
$ export LANG=en_US.UTF-8; time grep -c Quit /var/log/mysqld.log
Try strace-ing grep with and without LANG=C
Just a handy way to get all the unique links from inside all the html files inside a directory. Can be handy on scripts etc.
Handy when you need to create a list of files to be updated when subversion is not available on the remote host. You can take this tar file, and upload and extract it where you need it. Replace M and N with the revisions specific to yours. Make sure you do this from an updated (svn up) working directory.
This one would be much faster, as it's only one executed command.
this command searches for a keyword or an expression in a path and avoids versionned files
By putting the "-not \( -name .svn -prune \)" in the very front of the "find" command, you eliminate the .svn directories in your find command itself. No need to grep them out.
You can even create an alias for this command:
alias svn_find="find . -not \( -name .svn -prune \)"
Now you can do things like
svn_find -mtime -3
Solves "tr" issues with non C-locales under BSD-like systems (like OS X)
A short, *easy-er* to remember command for stripping whitespace and comments from a config file, (or any file for that matter).
Remember regex as:
slash, space, star.
pound, slash, bar.
pointy-hat, dollar. (or "caret, dollar" if you must)
Skype has an internal regex which depicts the emoticons it supports. However you cannot simply search the binary file for it. This small 181 character line will do just that, provided skype is running. And of course, only works in linux.
get desired info from machine and pipe it txt file.
Uses logger in a while loop to log memory statistics frequently into the local syslog server.
additionally use "find /etc/cron*" for cronscripts
I had some trouble removing empty lines from a file (perhaps due to utf-8, as it's the source of all evil), \W did the trick eventually.
Using the grep command, retrieve all lines from any log files in /var/log/ that have one of the problem states
This set of commands was very convenient for me when I was preparing some xml files for typesetting a book. I wanted to check what styles I had to prepare but coudn't remember all tags that I used. This one saved me from error-prone browsing of all my files. It should be also useful if one tries to process xml files with xsl, when using own xml application.
find all email addresses in a file, printing each match. Addresses do not have to be alone on a line etc. For example you can grab them from HTML-formatted emails or CSV files, etc. Use a combination of
to filter them.