Some times, we may be in situation to find the list of files in a recursive directory and search for a specific contents in it.
Below is the command which does that. In below command I'm trying to find commons-beanutils.jar recursive in a directory and a grep command on the listed files to actually find do the jar files has class file 'BeanUtilsBean.class in it.
find . -name *beanutils*.jar -exec grep 'BeanUtilsBean.class' '{}' \;
About Me
Showing posts with label find. Show all posts
Showing posts with label find. Show all posts
Wednesday, 9 February 2011
Thursday, 24 September 2009
To touch a folder contents recursive
Some times you may need to alter the access date of files and folder. You can do it by a recursive touch command.
find . | xargs touch
find . | xargs touch
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.
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.
Subscribe to:
Posts (Atom)
