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 . -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)

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 info | grep ^URL | awk -F\/ '{print $NF}'
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 status | grep "^\?" | awk '{print $2}' | xargs svn add
2009-03-12 15:06:12
User: unixfu73000
Functions: awk grep xargs
Tags: svn
-1

This adds all new files to SVN recursively. It doesn't work for files that have spaces in their name, but why would you create a file with a space in its name in the first place?

find . -name "\.svn" -exec rm -rf {} ";"
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

vimdiff file1 file2
find . -type d -name DIR -print0 | xargs -r0 rm -r
2009-03-04 14:49:21
User: miguelbaldi
Functions: find rm xargs
Tags: svn cvs
-2

You can use this command to delete CVS/svn folders on given project.

svn st | cut -c 9- | parallel -X tar -czvf ../backup.tgz
2010-01-28 11:43:16
Functions: cut tar
-2

xargs deals badly with special characters (such as space, ' and "). In this case if you have a file called '12" record'.

Parallel https://savannah.nongnu.org/projects/parallel/ does not have this problem.

Both solutions work bad if the number of files is more than the allowed line length of the shell.

svn log -q | grep -v "^-" | cut -d "|" -f 2 | sort -u
xdg-open $(svn info | sed -n '/URL:/s/URL: //p')
curl -s http://whatthecommit.com | sed -n '/<p>/,/<\/p>/p' | sed '$d' | sed 's/<p>//'
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 revert .
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

tar --exclude='.svn' -c -f /path/to/file.tar /path/to/directory