About Me

My photo
Working as Technical Lead in CollabNET software private limited.

Tuesday, 31 March 2009

Find and Grep

The find and grep are very usefull commands for development.

When you want to grep a content for the matching files, below commands will help you out.


In linux:
find /tmp -name 'page.xml' -print0 | xargs -0 grep "view_link=\"ReportView" | awk '{print $1}' | wc -l

In solaris:
find /tmp -name 'page.xml' -exec grep "view_link=\"ReportView" {} \; | wc -l

In the above command I'm trying to find page.xml inside /tmp dir and then search content "view_link=\"ReportView" from the find output.

No comments: