grep -L "the pattern" * # to recurse into subdirectories grep -RL "the pattern" *
Tag Archive for find
Grep for files that do not match a pattern
SED Find and Replace First Occurrence
gsed '0,/find/s//replace/'
Find & Replace
UPDATE table_name SET column_name = REPLACE(column_name, 'http://oldcontent.com', 'http://newcontent.com');
Use Linux Find and Awk to Locate Large Files
find / -type f -size +20000k -exec ls -lh {} ; | awk '{ print $NF ": " $5 }'
Find in Files
find . | xargs grep 'string' -sl
// or alternatively
find ./ -exec grep -Hn "YourString" {} ;
Linux Command for Listing all files which contains the word ‘abc’
find / -type f -exec grep -H 'abc' {} ;
grep string in file type
## To find by file type in this case, .e and .pl files ## replace <string> with desired string to grep for... find . | egrep -i ".(e|pl)" | xargs grep <string>
grep string in file type
## To find by file type in this case, .e and .pl files ## replace <string> with desired string to grep for... find . | egrep -i ".(e|pl)" | xargs grep <string>
Find All The Links On A Page
$html = file_get_contents('http://www.example.com');
$dom = new DOMDocument();
@$dom->loadHTML($html);
// grab all the on the page
$xpath = new DOMXPath($dom);
$hrefs = $xpath->evaluate("/html/body//a");
for ($i = 0; $i < $hrefs->length; $i++) {
$href = $hrefs->item($i);
$url = $href->getAttribute('href');
echo $url.'<br />';
}
Search and replace through a whole directory tree
find . -type f -exec sed -i 's/STRING1/STRING2/' {} ;