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 subversion from sorted by
Terminal - Commands tagged subversion - 16 results
svn log -v --xml > log.xml; zorba -q 'let $log := doc("log.xml")/log/logentry return for $author in distinct-values($log/author) order by $author return concat($author, " ", sum(count($log[author=$author]/paths/path)), "
")' --serialize-text
2013-03-22 11:17:10
User: langec
Functions: return
1

This saves Subversion's log output as XML and then runs an XQuery over it. This is standard XQuery 1.0 and should therefore also work with other XQuery processors. I have tested it with Zorba (http://www.zorba-xquery.com). XQilla (http://xqilla.sourceforge.net) also does it, but you'd have to save the query to a file and then execute "xqilla filename.xq".

The query first finds all distinct authors and then, for each author, sums up the number of paths they have changed in each commit. This accounts for commits of multiple changes at once.

The indenting space in all lines from the second one seems to be due to a bug in Zorba.

svnlook date /path/to/repo
2012-04-03 16:29:00
User: ijeyanthan
Functions: date
0

command to find out the unused SVN repositories from the server via svnlook. This lists the when the last commit (HEAD revision) has happened in the repository.

svnll(){svn log "$@"|( read; while true; do read h||break; read; m=""; while read l; do echo "$l" | grep -q '^[-]\+$'&&break; [ -z "$m" ] && m=$l; done; echo "$h % $m" | sed 's#\(.*\) | \(.*\) | \([-0-9 :]\{16\}\).* % \(.*\)#\1 \2 (\3) \4#'; done)}
2012-03-25 20:39:05
User: vhotspur
Functions: echo grep read sed
Tags: log subversion
0

Emulate (more or less) Git equivalent of

git log --format='tformat:%h %an (%cr) %s'
sudo svn co svn+ ciccio_diverso://root@192.160.150.151/svn-repo/progettino
2012-02-03 18:16:02
User: 0disse0
Functions: sudo
Tags: subversion
0

first need to Edit the configuration file

/home/cicciobomba/.subversion

and under the [tunnels] add this line

ciccio_diverso = /usr/bin/ssh -p 12345

svn diff --diff-cmd='meld' -r 100:BASE FILE
svn info -R --xml file:///path/to/rep | grep kind=\"file\"|wc -l
2011-12-06 20:06:42
User: ijeyanthan
Functions: grep info wc
Tags: svn subversion
2

Number of files in a SVN Repository

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

svn log -r '{YYYY-MM-DD}:{YYYY-MM-DD}' | sed -n '1p; 2,/^-/d; /USERNAME/,/^-/p' | grep -E -v '^(r[0-9]|---|$)' | sed 's/^/* /g'
2010-12-22 17:52:19
User: antic
Functions: grep sed
1

* Replace USERNAME with the desired svn username

* Replace the first YYYY-MM-DD with the date you want to get the log (this starts at the midnight event that starts this date)

* Replace the second YYYY-MM-DD with the date after you want to get the log (this will end the log scan on midnight of the previous day)

Example, if I want the log for December 10, 2010, I would put {2010-12-10}:{2010-12-11}

find . -type d -not \( -name .svn -prune \) -exec svn propset svn:ignore '*' {} \;
2010-08-15 03:45:57
User: tristan_ph
Functions: find
0

If you would like to ignore a directory including its subdirectory. For example, a tmp/ directory

find . -name .svn -exec rm \-rf {} \;
for d in $(find . -maxdepth 1 -type d -name '[^.]*'); do cd "$d"; svn up; cd ..; done
2010-05-28 10:09:19
User: udog
Functions: cd find
-2

If you have a directory with many working copies of various subversion projects and you want to update them all at once, this one may be for you.

(for i in `find . -maxdepth 2 -name .svn | sed 's/.svn$//'`; do echo $i; svn info $i; done ) | egrep '^.\/|^URL'
2010-05-09 11:54:37
User: jespere
Functions: echo egrep info sed
0

If you have lots of subversion working copies in one directory and want to see in which repositories they are stored, this will do the trick. Can be convenient if you need to move to a new subversion server.

find . -type d -name .svn -exec chmod g+s "{}" \;
2010-04-27 16:51:00
User: mitzip
Functions: chmod find
2

The above command will set the GID bit on all directories named .svn in the current directory recursively. This makes the group ownership of all .svn folders be the group ownership for all files created in that folder, no matter the user.

This is useful for me as the subversion working directory on my server is also the live website and needs to be auto committed to subversion every so often via cron as well as worked on by multiple users. Setting the GID bit on the .svn folders makes sure we don't have a mix of .svn metadata created by a slew of different users.

export FIGNORE=.svn
2010-04-09 15:26:00
User: peter0081
Functions: export
13

When browsing java source code (for example) it's really annoying having to type the first letter of the package when there is only one package in the subdir.

man bash for more info about FIGNORE

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.

svn up | sed 's/\.//g' | cut -d ' ' -f3 | xargs svn log -r
find -type d -name ".svn" -prune -o -not -empty -type f -printf "%s\n" | sort -rn | uniq -d | xargs -I{} -n1 find -type d -name ".svn" -prune -o -type f -size {}c -print0 | xargs -0 md5sum | sort | uniq -w32 --all-repeated=separate
2010-01-28 09:45:29
User: 2chg
Functions: find md5sum sort uniq xargs
2

Improvement of the command "Find Duplicate Files (based on size first, then MD5 hash)" when searching for duplicate files in a directory containing a subversion working copy. This way the (multiple dupicates) in the meta-information directories are ignored.

Can easily be adopted for other VCS as well. For CVS i.e. change ".svn" into ".csv":

find -type d -name ".csv" -prune -o -not -empty -type f -printf "%s\n" | sort -rn | uniq -d | xargs -I{} -n1 find -type d -name ".csv" -prune -o -type f -size {}c -print0 | xargs -0 md5sum | sort | uniq -w32 --all-repeated=separate