Liam Delahunty: Home Tips Web Contact
Recommended laptop
under £500
.

Think I deserve a present? See my Amazon Wish List

Linux Find files Prune, Ignore Directories, Xargs Grep

find . -path './media/' -prune -o -iname '*php' \! -type d -print0 | xargs -0 grep -il Term

find . -path - Find all files in this directory (.) The -path is required as we are going to prune a directory

-prune - ignore the contents of the proceding path './media/'

-iname - files must have php in the name. Specifically end with php

\! -type d - ignore directory names

-print0 - print results in a way that spaces won't screw up the xargs

| - pipe the results of the first command into the second

xargs - build and execute command lines from standard input

-0 - to process arbitrary file names, even those that contain newline characters

grep - Search for the "Term" -i case insensitive -l list only the results.

I use this command to find pages in websites with particular terms, and want to avoid parsing the files of certain directories (media), only for certain file types (*php) and ignore directory names.

Share this!  



Linux Find Files Edited Today | Linux Find Prune And Ignore Directories | Linux Find Prune Directory


 

  Tips | Home | Search | Contact

Link here: