Hide

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.

Hide

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:

Hide

News

2011-03-12 - Confoo 2011 presentation
Slides are available from the commandlinefu presentation at Confoo 2011: http://presentations.codeinthehole.com/confoo2011/
2011-01-04 - Moderation now required for new commands
To try and put and end to the spamming, new commands require moderation before they will appear on the site.
2010-12-27 - Apologies for not banning the trolls sooner
Have been away from the interwebs over Christmas. Will be more vigilant henceforth.
2010-09-24 - OAuth and pagination problems fixed
Apologies for the delay in getting Twitter's OAuth supported. Annoying pagination gremlin also fixed.
Hide

Tags

Hide

Functions

Commands tagged svn from sorted by
Terminal - Commands tagged svn - 92 results
svn diff | view -
svn ls -R | egrep -v -e "\/$" | xargs svn blame | awk '{print $2}' | sort | uniq -c | sort -r
2009-07-29 02:10:45
User: askedrelic
Functions: awk egrep ls sort uniq xargs
Tags: svn count
16

I'm working in a group project currently and annoyed at the lack of output by my teammates. Wanting hard metrics of how awesome I am and how awesome they aren't, I wrote this command up.

It will print a full repository listing of all files, remove the directories which confuse blame, run svn blame on each individual file, and tally the resulting line counts. It seems quite slow, depending on your repository location, because blame must hit the server for each individual file. You can remove the -R on the first part to print out the tallies for just the current directory.

svn diff <file> | vim -R -
2009-06-13 22:00:49
User: caiosba
Functions: diff vim
Tags: svn vim diff color
14

Simple way to achieve a colored SVN diff

grep -r --exclude-dir=.svn PATTERN PATH
2009-03-04 23:21:50
User: patko
Functions: grep
Tags: svn
8

exclude-dir option requires grep 2.5.3

zip -r foo.zip DIR -x "*/.svn/*"
svn log -r {`date "+%Y-%m-%d"`}:HEAD|grep '^r[0-9]' |cut -d\| -f2|sort|uniq -c
svn propset svn:ignore "*txt" log/
2009-04-04 23:09:01
Tags: svn
5

If you don't want to commit files to subversion, and don't want those file to show up when doing an "svn stat", this command is what you need

find . -not \( -name .svn -prune \)
2009-05-20 19:45:24
User: mbirk
Functions: find
Tags: svn find
5

The "find" command can be annoying when used inside of a Subversion (or CVS) working directory. Obviously, you can combine this with other predicates and commands to create a more elaborate pipeline:

find /var/svn -type f -not \( -name .svn -prune \) -print0 | xargs -0 md5sum

Note: You can use my "dont-go-there.sh" script to wrap the "find" command and do this automatically at http://forwardlateral.com/blog/2006/02/27/dont-go-there/

find . -name .svn -prune -o -print
2009-09-04 17:41:33
User: arcege
Functions: find
Tags: svn find
5

Put the positive clauses after the '-o' option.

svn log -r {`date +"%Y-%m-%d" -d "1 month ago"`}:HEAD|grep '^r[0-9]' |cut -d\| -f2|sort|uniq -c
svn st | grep -e '^M' | awk '{print $2}' | xargs svn revert
svn log -v -r{2009-05-21}:HEAD | awk '/^r[0-9]+ / {user=$3} /yms_web/ {if (user=="george") {print $2}}' | sort | uniq
2009-06-05 14:07:28
User: jemptymethod
Functions: awk sort
Tags: svn awk log
4

just change the date following the -r flag, and/or the user name in the user== conditional statement, and substitute yms_web with the name of your module

svn ci `svn stat |awk '/^A/{printf $2" "}'`
find . -name .svn -exec rm \-rf {} \;
rsync -rv --exclude .svn src/dir/ dest/dir/
curl http://whatthecommit.com/index.txt
svn log -v --xml file:///path/to/rep | grep kind=\"file\"|wc -l
2010-03-23 12:16:06
User: andremta
Functions: grep wc
Tags: svn subversion
3

This command will output the total number of files in a SVN Repository.

rsync -vazuK --exclude "*.mp3" --exclude "*.svn*" * user@host:/path
2009-02-27 19:58:02
User: sudopeople
Functions: rsync
Tags: svn exclude
2

rsyncs files to a server excluding listed files

also a file can be used to exclude common exclude rules and/or to exclude a ton of files, like so:

rsync --exclude-from '~/.scripts/exclude.txt'

where exclude.txt has one rule per line:

*.mp3

*.svn*

function svnundopoint() { if [ -d .undo ]; then r=`svn info | grep Revision | cut -f 2 -d ' '` && t=`date +%F_%T` && f=${t}rev${r} && svn diff>.undo/$f && svn stat>.undo/stat_$f; else echo Missing .undo directory; fi }
2009-03-27 07:14:31
User: codeape
Functions: cut echo grep info
Tags: bash svn
2

Allows you to save progress without committing.

To revert to an undo point, svn revert then apply the undo point with patch.

svn revert -R . && patch -p0 < .undo/2009-03-27_08:08:11rev57

Similar: http://www.commandlinefu.com/commands/view/373/archive-all-files-containing-local-changes-svn

svn info | grep '^URL:' | egrep -o '(tags|branches)/[^/]+|trunk' | egrep -o '[^/]+$'
2009-04-09 20:08:45
User: isaacs
Functions: egrep grep info
Tags: svn grep
2

Get the svn info, grep for the "URL" of the repository, pull out the tag/branch/trunk, and then just show the helpful/meaningful bit.

svn status | grep "^\?" | awk '{print $2}' | xargs svn add
svn log fileName|cut -d" " -f 1|grep -e "^r[0-9]\{1,\}$"|awk {'sub(/^r/,"",$1);print "svn cat fileName@"$1" > /tmp/fileName.r"$1'}|sh
2009-05-27 02:11:58
User: fizz
Functions: awk cut grep
Tags: bash svn awk grep
2

exported files will get a .r23 extension (where 23 is the revision number)

URL=http://svn.example.org/project; diff -u <(TZ=UTC svn -q log -r1:HEAD $URL | grep \|) <(TZ=UTC svn log -q $URL | grep \| | sort -k3 -t \|)
2009-06-03 14:26:55
User: sunny256
Functions: diff grep sort
Tags: bash svn
2

Lists revisions in a Subversion repository with a timestamp that doesn't follow the revision numbering order. If everything is OK, nothing is displayed.

svn log fileName | sed -ne "/^r\([0-9][0-9]*\).*/{;s//\1/;s/.*/svn cat fileName@& > fileName.r&/p;}" | sh -s
2009-09-04 17:23:45
User: arcege
Functions: sed sh
Tags: svn sed shell
2

Manages everything through one sed script instead of pipes of greps and awks. Quoting of shell variables is generally easier within a sed script.

vimdiff <(svn cat "$1") "$1"
2009-09-04 18:41:40
User: plasticboy
Functions: cat
Tags: svn vim diff color
2

This will diff your local version of the file with the latest version in svn. I put this in a shell function like so:

svd() { vimdiff <(svn cat "$1") "$1"; }