What's this?

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/

Get involved!

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.

Universal configuration monitoring and system of record for IT.

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:



May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!

Top Tags





Commands using ls from sorted by
Terminal - Commands using ls - 463 results
npm ls -g|grep "^[├└]\(.\+\)\?[┬─] "
ls | tr [:upper:] [:lower:] | grep -oP '\.[^\.]+$' | sort | uniq -c | sort
2014-01-30 11:37:27
User: icefyre
Functions: grep ls sort tr uniq

displays a list of all file extensions in current directory and how many files there are of each type of extension in ascending order (case insensitive)

ls -1 | xargs ruby -e'puts ARGV.shuffle'
ls -l /usr/share/xsessions/
2014-01-17 05:09:18
User: puresky
Functions: ls

Sometimes there are just no variables such as $DESKTOP_SESSION, $GDMSESSION, or $WINDOWMANAGER.

ls --color=never -1| grep -E "[0-9]{4}"|sed -re "s/^(.*)([0-9]{4})(.*)$/\2 \1\2\3/" | sort -r
for i in $(ls *.mp3); do mplayer $i && echo "delete it? [y/n]" && read trash && if [ "$trash" == "y" ]; then rm $i; fi; do
2013-12-23 20:09:56
User: wibbel4
Functions: echo ls read rm

Old drive with lots of music or unsorted drive? This command will play all mp3 files in a folder and after playing one song or pressing q, it will ask you if you want to delete the file.

ls -d .??*
2013-12-17 19:06:30
User: pydave
Functions: ls
Tags: bash glob

You can omit the -d to see what's inside directories. In that case, you may want -a to see dotfiles inside those directories. (Otherwise you don't need -a since you're explicitly looking at them.)

ls -ls -tr | tail
ls -al | awk '/^-rwx/ {print $9}'
find ~ -type f -size +500M -exec ls -ls {} \; | sort -n
2013-11-17 13:13:14
User: marcanuy
Functions: find ls sort
Tags: size find

Find all files larger than 500M in home directory and print them ordered by size with full info about each file.

find *.less | xargs -I {} lessc {} {}.css && ls *.less.css | sed -e 'p;s/less.css/css/' | xargs -n2 mv
while true; do ls -lah && sleep 1; done
2013-10-20 07:16:49
User: exolon
Functions: ls sleep

This one works without an external program (watch). Witch is not await able all the time. HINT: use CTRL + C to exit the loop.

ls -R | grep -v skipme | xargs rm -Rf
2013-10-18 08:11:39
Functions: grep ls rm xargs
Tags: delete rm

This command will delete all files and folders except 'skipme'. it could be a file or a folder.

ls -lR | less
watch --interval 1 ls -lah
2013-10-16 10:41:15
User: c0r3dump3d
Functions: ls watch

Use this command if you want to control the size of the files in human readable, every one second.

ls -l `find . -maxdepth 1 -type l -print`
find . -name '*pdf*' -print0 | xargs -0 ls -lt | head -20
2013-10-03 21:58:51
User: fuats
Functions: find head ls xargs

Sorts by latest modified files by looking to current directory and all subdirectories

for AAA in $(find /usr/local/bin -type l); do ls -gG "${AAA}"; done
2013-10-01 10:49:12
User: rgregor
Functions: find ls

Display a list of local shell scripts soft-linked to /usr/local/bin

Put local shell scripts to local ~/bin/ directory and soft-link them to /usr/local/bin/ which is in the $PATH variable to run them from anywhere.

find ./ -type f -size +500k -exec ls -1Ash {} \; | sort -hr | cat -n
2013-10-01 10:32:28
User: rgregor
Functions: cat find ls sort

"find ./ ..." could be replaced with "find $PWD ..." to display absolute path instead of relative path.

watch -d -n 2 'df; ls -FlAt;'
find (); { ls $1 | while read line; do [[ -d $1/$line ]] && find $1/$line $2 || echo $1/$line | grep $2; done; }
2013-07-28 22:21:39
User: a8ksh4
Functions: echo find grep ls read

basic find implementation for systems that don't actually have find, like an android console without busybox installed.

ls | xargs -I{} du -sh {}
for i in {1..31}; do ls -1 *${YYYY}${MM}`printf "%02d" $i`* | wc -l; done
2013-07-26 07:08:04
User: Paulus
Functions: ls wc
Tags: bash Linux

RU: Найдет число файлов в папке по данной маске в цикле по дням месяца

ls -1F | grep @$ | sed 's/@//' | column
2013-07-19 17:55:11
User: jlbknr
Functions: grep ls sed
Tags: ls symlinks

I use this with alias:

alias lsl="ls -1F | grep @$ | sed 's/@//' | column"

Limitation: This will also list files that happen to have an @ at the end of the filename.

$ ls -1F | grep @ | sed 's/@//' | column
2013-07-19 17:41:03
User: jlbknr
Functions: grep ls sed
Tags: ls symlinks

I use this with alias:

alias lsl="ls -1F | grep @ | sed 's/@//' | column"