• Top
  • Comment
  • Reply

Filtering SVN Status results

I frequently have to run the svn status using a pipe to grep for filtering only specific svn flags (A, M, G, ? ...). However I got board and made a script so I can pipe the output of svn status, to my handy little script to make life easier

# This script is usefull for when checking so status
# @author: Shahmir Javaid

#Run the `tty` command and exit if the `so` command was run directly for terminal
#This is to make sure, that `so` command is only ran as a piped command
if [ "$( tty )" != 'not a tty' ]; then
    echo "'so' needs to be piped, Works best with 'svn status | so'"
    exit 1

if [ $# -eq 1 ]; then
    CATRET=`cat - | egrep "^["$1"]"`
    CATRET=`cat - | egrep "^[^?]"`

if [ -z "$CATRET" ]; then
    echo "Nothing to be updated"
    echo "$CATRET"

exit 0

A Normal svn status

shahmir@localhost www> svn status
?         index.php
?         input/list1.a
?         input/list2.a
M        contact.php
A        default.css

Running svn status with it piped to so will return only the flags that dont have ?.

shahmir@localhost www> svn status | so
M        contact.php
A        default.css

You can also pass in a parameter to show only specific flags

shahmir@localhost www> svn status | so A
A        default.css

An empty output will return, You can change this to what you like.

shahmir@localhost www> svn status | so G
Nothing to be updated

If anyone wishes to expand on this. Please comment and i will add it here, with credits ofcourse.

P.S. use this script however whenever without legals :D


24th Jan 2012
© 2011 Shahmir Javaid - http://shahmirj.com/blog/21

Erick Xavier

8th Oct 2013

or just do:

show only added files:
> svn st | grep ^A

show only modified files:
> svn st | grep ^M

show only scheduled to delete files:
> svn st | grep ^D

Chris Carter

5th May 2014

From http://stackoverflow.com/a/5707181/639739

show all conflicts (only if your grep has -P for perl syntax):
> svn status | grep -P '^(?=.{0,6}C)'

Back to Top
All content is © copyrighted, unless stated otherwise.
Subscribe, @shahmirj, Shahmir Javaid+