Feb 22, 2010 #1 mendof Technical User Joined Feb 22, 2010 Messages 2 Location CZ Hi all, I am struggling to get specific string in some files. I am using find . -iname "*.xml " -print -exec cat {} \; | grep -i "*string*" and I can find string, but filenames I cannot see... Any comment is welcome and thanks in advance Regards, mendof
Hi all, I am struggling to get specific string in some files. I am using find . -iname "*.xml " -print -exec cat {} \; | grep -i "*string*" and I can find string, but filenames I cannot see... Any comment is welcome and thanks in advance Regards, mendof
Feb 22, 2010 1 #2 feherke Programmer Joined Aug 5, 2002 Messages 9,541 Location RO Hi If you not need to search recursively, then : Code: grep -i "*string*" *.xml If you have to search in sub-directories too : Code: grep -ri "*string*" . | grep .xml: But if you want to keep your [tt]find[/tt] & [tt]grep[/tt] combination " Code: find . -iname "*.xml" -exec grep -Hi "*string*" '{}' \; Tested with GNU [tt]grep[/tt]. Feherke. http://free.rootshell.be/~feherke/ Upvote 0 Downvote
Hi If you not need to search recursively, then : Code: grep -i "*string*" *.xml If you have to search in sub-directories too : Code: grep -ri "*string*" . | grep .xml: But if you want to keep your [tt]find[/tt] & [tt]grep[/tt] combination " Code: find . -iname "*.xml" -exec grep -Hi "*string*" '{}' \; Tested with GNU [tt]grep[/tt]. Feherke. http://free.rootshell.be/~feherke/
Feb 22, 2010 Thread starter #3 mendof Technical User Joined Feb 22, 2010 Messages 2 Location CZ Hi, thank you. Last option is one I wanted to use, as I want to search in many directories for .xml files and specific string in them. Last option works, thanks a lot Regards, mendof Upvote 0 Downvote
Hi, thank you. Last option is one I wanted to use, as I want to search in many directories for .xml files and specific string in them. Last option works, thanks a lot Regards, mendof
Feb 22, 2010 #4 PHV MIS Joined Nov 8, 2002 Messages 53,708 Location FR A more legacy way: Code: find . -name '*.xml' | xargs grep -i '*string*' Hope This Helps, PH. FAQ219-2884 FAQ181-2886 Upvote 0 Downvote
A more legacy way: Code: find . -name '*.xml' | xargs grep -i '*string*' Hope This Helps, PH. FAQ219-2884 FAQ181-2886