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.
If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/
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:
short command to find a string in all text files in all subdirectories, excluding all files grep does not deem text files.
grep -o puts each occurrence in a separate line
The -p parameter tell the netstat to display the PID and name of the program to which each socket belongs or in digestible terms list the program using the net.Hope you know what pipe symbol means!
Presently we wish to only moniter tcp connections so we ask grep to scan for string tcp, now from the op of grep tcp we further scan for regular expression /[a-z]*.
Wonder what that means ?
If we look at the op of netstat -p we can see that the name of the application is preceded by a / ( try netstat -p ) so,now i assume application name contains only characters a to z (usually this is the case) hope now it makes some sense.Regular expression /[a-z]* means to scan a string that start with a / and contains zero or more characters from the range a-z !!. Foof .. is t
grep's -c outputs how may matches there are for a given file as "file:N", cut takes the N's and awk does the sum.
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.