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 by voyeg3r from sorted by
Terminal - Commands by voyeg3r - 22 results
kded --version | awk -F: 'NR == 2 {print $2}' | sed 's/\s\+//g'
2012-01-17 17:44:23
User: voyeg3r
Functions: awk sed

kded --version return this

Qt: 3.3.8b

KDE: 3.5.10

KDE Daemon: $Id: kded.cpp 711061 2007-09-11 09:42:51Z tpatzig $

awk -F: ................. Awk Field separator

NR == 2 ................. Register Number, second line

{print $2} ............... second field

sed 's/\s\+//g' .......... remove one space or more \s\+ changing by nothing

export PS1="[\u@`hostname -I` \W]$ "
2011-10-25 18:22:55
User: voyeg3r
Functions: export

when working with many machines in a computer lab need to know the IP addr is very large, this is a simplistic solution to make things easier

imap <leader>r <C-r>=system('echo "$(($RANDOM % 100))"')<cr>
2010-10-24 00:37:44
User: voyeg3r

This mapping function is called RANDOM bash and enter a number between 1 and 100

tar zxvf package.tar.gz --strip 1
2010-05-18 21:01:23
User: voyeg3r
Functions: tar

if I need get olnly script.sh from "folder/script.sh"

cat file | sed -n -r '/^100$|^[0-9]{1,2}$/p'
2010-05-15 19:15:56
User: voyeg3r
Functions: cat file sed

-r to use extended regex

^ begin line

| alternative

get 100 or 0-9 one or two times

ping -c 2 `arp-scan | awk '/00:1b:11:dc:a9:65/ {print $1}'`
2010-05-11 13:12:43
User: voyeg3r
Functions: awk ping

# first install arp-scan if not have it

arp-scan .... show ip+mac in localnet

awk '/00:1b:11:dc:a9:65/ {print $1}' .... get ip associated with MAC

` backtick make do command substitution passing ip to command ping

2010-04-04 18:54:14
User: voyeg3r

vim 7 or higher has internal sort, too 'sort n' for numbers

sed -i.backup '/patter/{n;s/foo/bar/g}' file
awk '/inet end/ {print $3}' <(ifconfig eth0)
awk 'NR==2 {print $1}' /proc/net/arp
free -m | awk '/Swap/ {print $4}'
2009-09-02 11:46:17
User: voyeg3r
Functions: awk free

simple way to show free swap

awk '!a[$0]++' file
2009-08-23 15:28:43
User: voyeg3r
Functions: awk

This create an array 'a' with wole lines. only one occurrence of each line - Not Get lines ++ !

awk '!($0 in a) {a[$0];print}' file
file -i * | grep 'text/plain' | wc -l
2009-08-16 21:22:46
User: voyeg3r
Functions: file grep wc

get files without extensions, get ASCII and utf-8 as "text/plain"

:for i in range(1,255) | .put='192.168.0.'.i | endfor
:%s/^/\=line('.').' '
2009-08-16 17:48:03
User: voyeg3r

Use this command to insert line numbers in source files, .' ' control how spaces you insert after number.

find ~/project -mtime -1 -type f -print | tar jcvf myfiles.tar.bz2 -T -
2009-03-13 13:03:11
User: voyeg3r
Functions: find tar

create tar.bz2 package from files "-type f" modificated today "-mtime -1" in ~/project

rsync -avz -e ssh --files-from=<(find -mtime +30 -mtime -60) source dest
2009-03-13 12:58:28
User: voyeg3r
Functions: find rsync ssh

rsync from source to dest all between >30

[[ -d dir ]] || mkdir dir ; cd dir
2009-03-12 17:19:13
User: voyeg3r
Functions: cd dir mkdir

For use in scripts this command is very usefull

mkdir -p doc/{text/,img/{wallpaper/,photos/}}
2009-03-12 17:15:58
User: voyeg3r
Functions: mkdir

create tree of dir's in one command

alias path='echo $PATH | tr ":" "\n"'
2009-03-12 17:07:58
User: voyeg3r
Functions: alias tr

change ":" in path for new line and associate word path to var $PATH

find . -maxdepth 1 -type f -print0 | xargs -0 -i cp ./{}{,.bak}
2009-03-12 16:02:13
User: voyeg3r
Functions: cp find xargs

"." is current dir, maxdepth is the level, -print0 | xargs -0 fix spaces in names, -i interactive , ./ is the current dir {} actual name , and {,.bak} is the atual name + bak