Find XML part in files

If you have a lot of XML files, like Magento Module Config Files, and need to find a code snippet, like the Crontab definitions in all files, try this:

find . -name '*.xml' | xargs awk '/<crontab>/,/<\/crontab>/{print FILENAME, $0; nextfile}'

It might also come in handy in Apache config files or other XML based config systems...
Dette indlæg blev udgivet i Knowledge Base. Bogmærk permalinket.

Skriv et svar