awk - grep command with two search criteria -


`i have contents of file below.

<path action="a" kind="file">/demo/svn_dev/src/classes/util - copy.cls</path><path action="d" kind="file">/demo/svn_dev/src/classes/admin.cls</path> <path action="m" kind="file">/demo/svn_dev/src/classes/adminutilctrl.cls</path> </paths> <msg>xyz</msg> 

i need retrive path of file if message contains string "xyz" , action="d" here need out put /demo/svn_dev/src/classes/admin.cls can 1 me grep command syntax. please let me know if need further information. help

you can't job grep. here's 1 way gnu awk multi-char rs , 3rd arg match():

$ cat tst.awk begin { rs="\\s*</[^>]+>\\s*" } match($0,/^<path\s*action="d"[^>]+>(.*)/,a) { act = a[1] } /^<msg>xyz$/ { print act }  $ awk -f tst.awk file /demo/svn_dev/src/classes/admin.cls 

Comments