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:
This of course assumes that lesspipe is installed. You can view the contents of many, many types of files in this way. Once lesspipe is installed, add to your .bashrc
export LESSOPEN="| /usr/bin/lesspipe %s" less file.jar
export LESSCLOSE="/usr/bin/lesspipe %s %s"
Usage : tt [OCCURRENCE]
tt will display a tree from your actual path
tt .svn will display only line containing .svn
Thanks th John_W for suggesting the fix allowing ~/ to be used when saving a directory.
Type in a url, it will show a preview of what the file will look like when saved, then asks if you want to save the preview and where you want to save it. Great for grabbing the latest commandlinefu commands without a full web browser or even a GUI. Requires: w3m
Validates and pretty-prints the content fetched from the URL.
LC_ALL=C man less | less +/ppattern
Really useful way to combine less and grep while browsing log files.
I can't figure out how to make it into a true oneliner so paste it into a script file called lgrep:
lgrep searchfor file1 [file2 file3]
Advanced example (grep for an Exception in logfiles that starts with qc):
lgrep Exception $(find . -name "qc*.log")
If you want a visual representation of the parent/child relationships between processes, this is one easy way to do it. It's useful in debugging collections of shell scripts, because it provides something like a call traceback.
When a shell script breaks, just remember "awwfux".
To sort hidden files first, simply switch the two inner `ls` commands.
I have this aliased to `dira`
`dir` is aliased to the simpler version with no hidden files:
ls -l --color=always | less -R
The "pstree" command uses special line-drawing characters. However, when piped into the "less" pager, these are normally disabled.
Get your colorized grep output in less(1). This involves two things: forcing grep to output colors even though it's not going to a terminal and telling less to handle those properly.
There is no need to 'zcat textfile.gz | less' with newer distros. This is useful for reading archived log files without having to extract, read, and zip when done.
This will print out the files and directories in a gzipped tarball.
The same as typing 'less filename' then 'G' or '>' or the END key. Comes in handy with shell scripts or aliases:
alias weblog='less +G /var/log/httpd/access_log'
alias errlog='less +G /var/log/httpd/error_log'
It allows customizing by means of lesspipe. You need to write a ~/.lessfilter script and put this into your ~/.bashrc:
This is equivalent to: less `which rcsyslog`
Using +F will put less in follow mode. This works similar to 'tail -f'. To stop scrolling, use the interrupt. Then you'll get the normal benefits of less (scroll, etc.).
Pressing SHIFT-F will resume the 'tailling'.
I put this in a shell script called "svndiff", as it provides a handy decorated "svn diff" output that is colored (which you can't see here) and paged. The -r is required so less doesn't mangle the color codes.