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 - 94 results
svn diff ARGUMENTS_FOR_DIFF | source-highlight --out-format=esc --src-lang=diff
svn status | egrep '^(M|A)' | egrep -o '[^MA\ ].*$'
2009-03-27 05:18:24
User: isaacs
Functions: egrep
Tags: svn
0

This is useful for piping to other commands, as well:

svn status | egrep '^(M|A)' | egrep -o '[^MA\ ].*$' | xargs $EDITOR
svn rm `svn status | grep "\!" | cut -c 8-`
2009-03-29 13:28:55
User: benschw
Functions: cut grep rm
Tags: svn
0

If (when) you forget to "svn rm" files from your repository, use this to let your repository know you want those files gone. Of course this works with adding and reverting too.

for i in `svn status | egrep '^(M|A)' | sed -r 's/\+\s+//' | awk '{ print $2 }'` ; do if [ ! -d $i ] ; then php -l $i ; fi ; done
2009-05-29 23:59:28
Functions: awk egrep sed
Tags: svn Linux PHP
0

Really only valuable in a PHP-only project directory. This is using standard linux versions of the tools. On most older BSD variants of sed, use -E instead of -r. Or use: sed 's/\+[[:space:]]\{1,\}//' instead.

find . -not \( -name .svn -prune \) -type f | xargs zip XXXXX.zip
find . -iname ".project"| xargs -I {} dirname {} | LC_ALL=C xargs -I {} svn info {} | grep "Last Changed Rev\|Path" | sed "s/Last Changed Rev: /;/" | sed "s/Path: //" | sed '$!N;s/\n//'
2009-10-07 16:13:27
User: hurz
Functions: dirname find grep info sed xargs
0

Searches for all .project files in current folder and below and uses "svn info" to get the last changed revision. The last sed joins every two lines.

svn add $(svn st|grep ^\?|cut -c2-)
2010-01-28 09:48:46
User: inkel
Functions: cut grep
Tags: bash svn grep cut
0

This version makes uses of Bash shell expansion, so it might not work in all other shells.

svn up | sed 's/\.//g' | cut -d ' ' -f3 | xargs svn log -r
svn pe svn:ignore .
svnradd() { for i in $1/*;do if [ -e "$i" ];then if [ -d "$i" ];then svn add $i;svnradd $i;else svn add $i;fi; fi;done }
2011-02-16 03:33:57
User: lkjoel
0

This will recursively add files/directories in SVN.

Usage:

svnradd yourfile

or

svnradd yourdirectory

then:

svn commit

Notice: It might not work properly, and not all files could get added.

Since there is a limit on characters, I couldn't add failure/success notices.

If you want failure/success notices, download Terminal Enhancements (http://tenhancements.tk/ )

It is included on Base Features

for R in `svn log file:///path/repo | grep ^r | grep dude | cut -d' ' -f1 | cut -dr -f2`; do svn ps svn:log --revprop -r $R "`svn pg svn:log --revprop -r $R file:///path/repo; perl -e 'print ".\n";' | fromdos`" file:///path/repo; done
2011-03-24 08:29:15
User: theist
Functions: cut grep ps
Tags: svn
0

Let's supose some moron used some m$ shit to commit to a later svnsynced repo. On a svn sync all his message logs cause a svnsync: Error setting property 'log': this commands finds all its contributions and fix all his commit logs

svn diff -r 1792:HEAD --summarize | awk '{if ($1 != "D") print $2}'| xargs -I {} tar rf incremental_release.tar {}
2011-04-05 15:00:49
User: windfold
Functions: awk diff tar xargs
Tags: bash svn awk xargs tar
0

The result of this command is a tar with all files that have been modified/added since revision 1792 until HEAD. This command is super useful for incremental releases.

svn ci -m "$(curl -s http://whatthecommit.com | sed -n '/<p>/,/<\/p>/p' | sed '$d' | sed 's/<p>//')"
2011-04-14 15:05:14
User: zbeekman
0

DO NOT RUN this command! THIS WILL CHECK IN ALL CHANGES IN THE CURRENT DIRECTORY TO SUBVERSION WITH A TERRIBLE COMMIT MESSAGE!!!!!!!!!!!!!!! DON'T DO IT! YOU'VE BEEN WARNED!

svn st | grep '^?' | sed -e 's/\?[[:space:]]*//' | tr '\n' '\0' | xargs -0 svn add
chflags -R nouchg ./
2011-08-17 08:39:16
User: matths
0

otherwise you get this error message:

svn: Can't move '.svn/tmp/entries' to '.svn/entries': Operation not permitted

svn status|grep -iR '^!'|sed 's/!/ /g'|xargs -i svn rm '{}'
2011-10-06 08:11:25
User: erdeszt
Functions: grep rm sed xargs
Tags: svn sed xargs grep
0

Helps if you accidentally deleted files from an svn repo with plain rm and you would like to mark them for svn to delete too.

svn log | perl -pe 's/\n//g => s/^-.*/\n/g'
2011-10-20 01:20:52
User: dbr
Functions: perl
Tags: svn perl svn log
0

dirrrty: use -p to chomp automatically, substitute all newlines away and then replace the "---" by a newline ? bingo!

s/// => s/// is just a cooler way to write s///, s/// which is just the small brother of s///; s/// (comma is an operator!)

have fun!

curl -s 'http://whatthecommit.com/' | grep '<p>' | cut -c4-
svn log -v -r{2009-11-1}:HEAD | awk '/^r[0-9]+ / {user=$3} /./{if (user=="george") {print}}' | grep -E "^ M|^ G|^ A|^ D|^ C|^ U" | awk '{print $2}' | sort | uniq
2011-12-05 07:36:44
User: smilyface
Functions: awk grep sort
Tags: svn awk log
0

svn log -v --> takes log of all

Filter1

--------

-r {from}{to} --> gives from and to revision

Filter2

--------

awk of line 'r'with numbers

Assign user=3rd column [ie; username]

Filter3

--------

if username = George

print details

Filter4

--------

Print lines starts with M/U/G/C/A/D

[* A Added * D Deleted * U Updated * G Merged * C Conflicted]

Filter5

--------

sort all files

Filter6

-------

Print only uniq file's name alone.

svn propget svn:externals -R [svn-repository-name]
for FILE in $(svn status | grep ? | grep .php); do svn add $FILE; done
2011-12-27 17:49:33
Functions: grep
Tags: svn PHP
0

simply change extension for others programming languages

svn diff <FILE>
2012-01-30 16:47:48
User: bbbco
Functions: diff
Tags: svn diff
0

If you have ever edited a locally checked out version of a file to tweak it for testing purposes, and came back to it over a weekend, you might have forgotten what you exactly changed. This command helps you see the differences between the the checked in SVN version, and the one you tweaked.

svn st | awk ' {if ( $1 == "?" ){print $1="",$0}} ' | sed -e 's/^[ \t]*//' | sed 's/ /\\ /g' | perl -ne '`svn add ${1}@` if /(.*)(@*)(.*)/'
2012-02-23 18:42:02
Functions: awk perl sed
Tags: svn perl
0

handels @, ?, whitespaces in names.

replace "?" and "add" by "!" and "rm" for svn mass remove.

---> I m looking for a nicer way to write it, perhaps with something using " perl -ne '`blahblah` if /\?(.*)/' "

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.

svn status | grep "^M" | while read entry; do file=`echo $entry | awk '{print $2}'`; echo $file; svn revert $file; done
2012-06-17 16:01:06
User: wsams
Functions: awk echo grep read
0

This command allows you to revert every modified file one-by-one in a while loop, but also after "echo $file;" you can do any sort of processing you might want to add before the revert happens.