All commands (14,187)

What's this?

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.

Share Your Commands


Check These Out

Split File in parts
Split File in 19 MB big parts, putting parts together again via cat Nameforpartaa Nameforpartab Nameforpartac >> File

Add all unversioned files to svn
No need for grep, let awk do the match. This will not behave properly if the filenames contains whitespace, which is awk's default field separator.

replace XX by YY in the the current directory and cd to it. ( in ZSH )
If you are in /begin/path/with/XX/pattern cd XX YY will change your current directory to /begin/path/with/YY/pattern in ZSH

Record output of any command using 'tee' at backend; mainly can be used to capture the output of ssh from client side while connecting to a server.
Optionally, you can create a new function to do this with a custom command. Edit $HOME/.bashrc and add: myssh () { ssh $1 | tee sshlog ; } Save it. At command prompt: $ myssh user@server

tail a log over ssh
This is also handy for taking a look at resource usage of a remote box. $ ssh -t remotebox top

Print a row of characters the width of terminal
Unlike other methods that use pipes and exec software like tr or sed or subshells, this is an extremely fast way to print a line and will always be able to detect the terminal width or else defaults to 80. It uses bash builtins for printf and echo and works with printf that supports the non-POSIX `-v` option to store result to var instead of printing to stdout. Here it is in a function that lets you change the line character to use and the length with args, it also supports color escape sequences with the echo -e option. $ function L() { local l=; builtin printf -vl "%${2:-${COLUMNS:-`tput cols 2>&-||echo 80`}}s\n" && echo -e "${l// /${1:-=}}"; } With color: $ L "`tput setaf 3`=" 1. Use printf to store n space chars followed by a newline to an environment variable "l" where n is local environment variable from $COLUMNS if set, else it will use `tput cols` and if that fails it will default to 80. 2. If printf succeeds then echo `$l` that contains the chars, replacing all blank spaces with "-" (can be changed to anything you want). From: http://www.askapache.com/linux/bash_profile-functions-advanced-shell.html http://www.askapache.com/linux/bash-power-prompt.html

Nmap list IPs in a network and saves in a txt

underscore to camelcase

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

Remove comments in XML file
In Redhat, xmlstarlet is called just xml which can be found in xmlstarlet RPM.


Stay in the loop…

Follow the Tweets.

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

Subscribe to the feeds.

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: