[hblug] Help with grep
Jim Tittsler
jtittsler at gmail.com
Sun Jul 13 10:39:49 NZST 2008
On Sun, Jul 13, 2008 at 9:54 AM, E Drummond <maggoty.haggis at gmail.com> wrote:
> I am trying to get the revision of a subversion repository and compare it
> with an existing revision. If the revision is newer, the repository needs to
> be checked out.
>
> To determine the current revision, I thought I could use grep:
> svn info https://spaceboyz.net/svn/aegisub/trunk | grep Revision
>
> This returns the whole revision line:
> Revision: 2245
>
> Basically what I need to do is only return the revision number, so I can
> compare it with the previous revision number. Is there a way to make grep
> return the next four characters after the string "Revision: " ?
You can use grep's -o to get part of a matched line:
svn info https://spaceboyz.net/svn/aegisub/trunk | grep Revision |
grep -o '[[:digit:]]\+'
But instead of using grep, I would think of awk first:
svn info https://spaceboyz.net/svn/aegisub/trunk | awk '/Revision:/ {print $2}'
> Google was not in a good mood today.
>
> - Erin
>
>
> _______________________________________________
> HBLUG mailing list
> HBLUG at linux.net.nz
> http://www.linux.net.nz/cgi-bin/mailman/listinfo/hblug
>
>
More information about the HBLUG
mailing list