Friday 2 September 2011

Useful commands

Below command ignores the .svn directory and searches the text in all the other directories and files,

grep "google" * -rn |grep -v .svn

Solaris doesn't support recursive grep, so i found the below command from google to be useful,

find . |xargs grep 'recursive'

To find the list of files changed in specific revision in Subversion

svn log -r --verbose REVNO

To find the list of files changed between two revisions in Subversion

svn diff -r 26767:26768 --summarize

List the files installed by a solaris package

pkgchk  -l  <> |grep Pathname

Find the date and time the rpm was modified

sh-3.2$  rpm -qa --queryformat '%{name}-%{version}-%{release} %{installtime:date}\n' |grep libgcc
libgcc-4.1.2-42.el5 Tue 15 Sep 2009 05:45:29 PM GMT


Revert the range of revisions from svn repository

cd working-copy

svn merge -r28431:28245  .

--- Reverse-merging r28431 through r28246

The above command will revert the changes made from revision 28426 to 28431  in your working copy . You need to Commit to update your changes to the server(repository) .

Match characters between two strings

lookbehind (?<=) 

look ahead (?=)
I need to find the Name of a person from the below statement,

Hi, Madhu , How are you

(?<=,)(.*)(?=,) - This will match Madhu in the statement as the pattern looks behind "," and looks ahead ","