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
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 st | grep '^?' | sed -e 's/\?[[:space:]]*//' | tr '\n' '\0' | xargs -0 svn add
lynx -dump -nolist http://whatthecommit.com/|sed -n 2p
2011-04-17 17:45:18
User: houghi
Functions: sed
-4

Fetch comical VC commit messages from whatthecommit.com

curl -s http://whatthecommit.com | html2text | sed '$d'
2011-04-14 16:51:53
User: zbeekman
Functions: sed
-1

Requires html2text. Print bad, but often funny commit messages from whatthecommit.com

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!

curl -s http://whatthecommit.com | sed -n '/<p>/,/<\/p>/p' | sed '$d' | sed 's/<p>//'
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 up -rREV file
svn diff -r M:N file.php | patch -p0
2011-03-29 04:15:02
User: ruslan
Functions: diff patch
1

M - current revision, N - older revision

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

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

svn st | awk ' {if ( $1 == "?" ){print $1="",$0}} ' | sed -e 's/^[ \t]*//' | sed 's/ /\\ /g' | xargs svn add
2011-02-09 14:02:54
Functions: awk sed xargs
Tags: svn
1

This should handle whitespaces well and will not get confused if your filenames have "?" in them

xdg-open $(svn info | sed -n '/URL:/s/URL: //p')
svn log -q | grep '^r[0-9]' | cut -f2 -d "|" | sort | uniq -c | sort -nr
2011-01-03 15:23:08
User: kkapron
Functions: cut grep sort uniq
2

list top committers (and number of their commits) of svn repository.

in this example it counts revisions of current directory.

svn status | grep '^?' | sed -e 's/^? */svn add "/g' -e 's/$/"/g'|sh ; svn status | grep '^!' | sed -e 's/^! */svn delete "/g' -e 's/$/"/g'|sh
svn log -q | grep -v "^-" | cut -d "|" -f 2 | sort -u
svn pe svn:ignore .
svn propedit svn:ignore .
2010-08-26 06:57:17
User: Tungmar
Tags: svn
2

Standard command, but I always have to search for it... ;-)

svn status | grep "^\?" | awk '{print $2}' | xargs svn add
2010-08-14 18:56:15
User: kureikain
Functions: awk grep xargs
Tags: svn awk grep
1

When working on a big proeject with SVN, you create quite much files, for now! Can just sit here and type svn add for all of them!

svn status will return a list of all of file which get ?(not add), "M"(Modified), "D"(Deleted)! This code just grep "?" flag, then add it into SVN again!

svn st | grep -e '^M' | awk '{print $2}' | xargs svn revert
find . -name .svn -exec rm \-rf {} \;
svn merge -c -REV
2010-06-21 15:11:13
User: shadycraig
Functions: merge
Tags: svn merge revert
1

This command can be used to revert a particular changeset in the local copy.

I find this useful because I frequently import files into the wrong directory. After the import it says "Committed revision 123" or similar. to revert this change in the working copy do:

svn merge -c -123 .

(don't forget the .) and then commit.

svn st | awk '{if ($1 ~ "?") print $2}' | xargs svn add
2010-06-19 03:07:26
User: sciurus
Functions: awk xargs
Tags: svn awk
1

No need for grep, let awk do the match. This will not behave properly if the filenames contains whitespace, which is awk's default field separator.

diff -wubBEr -x .svn dirA dirB
svn stat -u | sort | sed -e "s/^M.*/\o033[31m&\o033[0m/" -e "s/^A.*/\o033[34m&\o033[0m/" -e "s/^D.*/\o033[35m&\o033[0m/"
2010-03-26 15:44:04
Functions: sed sort stat
Tags: bash svn sed
1

Use color escape sequences and sed to colorize the output of svn stat -u.

Colors: http://www.faqs.org/docs/abs/HTML/colorizing.html

svn stat characters: http://svnbook.red-bean.com/en/1.4/svn-book.html#svn.ref.svn.c.status

GNU Extensions for Escapes in Regular Expressions: http://www.gnu.org/software/sed/manual/html_node/Escapes.html