4

I do svn status --show-updates and then I want to either

  • Q1: ignore (not to display) lines that start with ?
  • Q2: display only lines that start with * Note that there are few spaces before * occurs. That means that * is not the first character on the line.

How can I do that?

2 Answers 2

10

You can express those conditions using regular expressions and use grep to filter the results based on those.

The first one is ^?. The carat is a special character that represents the beginning of a line; so that expression matches the beginning of the line immediately followed by a ?.

The second one is ^ *\*. The * is a special character that qualifies the preceding character - it means the preceding character may appear zero or more times. Since * is a special character, the one you're looking for needs to be escaped, hence, \*. So that expression will match the beginning of a line followed by zero or more spaces, followed by an asterisk.

For your first condition, use the -v option for grep to negate the results.

So finally,

svn status --show-updates | grep -v '^?'

or

svn status --show-updates | grep '^ *\*'

Regular expressions are very powerful, so many Unix tools can use them. They are very much worth learning. There is a great tutorial at regular-expressions.info.

1
  • 2
    Depending on which grep, the ? may have special meaning. If so, you need to escape it \? Commented Feb 20, 2012 at 9:07
1

Q1: A simple way is the following

svn st --show-updates -q

st is the abbreviation for status, and -q for quiet : that will exclude files that aren't already added in the repository.

Q2: if you didn't named your files with a *, you can also do this:

svn status --show_updates|grep -v \*

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.