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 merge -r 854:853 l3toks.dtx
svn status | awk -F" " '{ for (i=2; i<=NF; i++) print "ls -ld \""$i"\""}' | sh
2014-07-09 09:41:24
User: kln0thing
Functions: awk
Tags: svn awk ls
0

The AWK part of the code will "collate" the fields from 2nd to Nth field (this is to handle any svn directories that may have spaces in them - typical when working with code that is interchangeably used with windows environment - for example, documentation teams) - the output is passed to "ls -ld" - the -d option to ls will tell ls to handle directories itself, rather than do ls on the directory. The '-p' option is just for pretty printing directories, links and executables (for added readability).

Finally, the entire "constructed" command will be passed onto sh for shell execution.

for i in $(find . -regex '.*\/C.*\.cpp'); do svn mv `perl -e 'my $s=$ARGV[0]; $s=~m/(.*\/)C(.*)/; print "$s $1$2"' "$i"`; done
svn info | sed -n "/URL:/s/.*\///p"
svn info | grep ^URL | awk -F\/ '{print $NF}'
svn ls -R | egrep -v -e "\/$" | xargs svn blame | awk '{count[$2]++}END{for(j in count) print count[j] "\t" j}' | sort -rn
2013-05-03 01:45:12
User: kurzum
Functions: awk egrep ls sort xargs
Tags: svn count
0

This one has a better performance, as it is a one pass count with awk. For this script it might not matter, but for others it is a good optiomization.

svn ls -R | egrep -v -e "\/$" | tr '\n' '\0' | xargs -0 svn blame | awk '{print $2}' | sort | uniq -c | sort -nr
2013-04-10 19:37:53
User: rymo
Functions: awk egrep ls sort tr uniq xargs
Tags: svn count
1

make usable on OSX with filenames containing spaces. note: will still break if filenames contain newlines... possible, but who does that?!

svn revert .
svn diff . -r43:HEAD --summarize | cut -c9-99999 | cpio -pvdmu ~/destination
2012-12-26 05:02:59
User: Sebasg
Functions: cpio cut diff
Tags: svn
0

Get the list of changed files between revision 43 and HEAD revision: svn diff . -r43:HEAD --summarize

Strip extra 8 characters from every line: cut -c9-99999

Copy the listed files to home/me/destination: cpio -pvdmu ~/destination

Make a plain copy (-p), list files being copied (-v), create needed directories (-d), preserve modification time (-m), overwrite unconditionally (-u)

for file in `svn st | awk '{print $2}'`; do svn revert $file; done
vimdiff file1 file2
find . -name ".svn" -type d -exec rm -rf {} \;
2012-08-16 13:04:47
User: gigo6000
Functions: find rm
Tags: svn git rm
-2

This is useful when you are uploading svn project files to a new git repo.

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.

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 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 /\?(.*)/' "

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.

curl http://whatthecommit.com/index.txt
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 propget svn:externals -R [svn-repository-name]
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 -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.

rsync -rv --exclude .svn src/dir/ dest/dir/
svn list -vR svn://server/repo/somedir | awk '{if ($3 !="") sum+=$3; i++} END {print "\ntotal size= " sum/1024000" MB" "\nnumber of files= " i/1000 " K"}'
2011-11-09 00:52:22
User: ndhail
Functions: awk
Tags: svn awk
1

afaik, svn doesn't have a good, scriptable way of telling you these two basic pieces of information.

curl -s 'http://whatthecommit.com/' | grep '<p>' | cut -c4-
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!