Tag Archive for find

Grep for files that do not match a pattern

grep -L "the pattern" *

# to recurse into subdirectories

grep -RL "the pattern" *

source

SED Find and Replace First Occurrence

gsed '0,/find/s//replace/'

source

Find & Replace

UPDATE table_name SET column_name = REPLACE(column_name, 'http://oldcontent.com', 'http://newcontent.com');

source

Use Linux Find and Awk to Locate Large Files

find / -type f -size +20000k -exec ls -lh {} ; | awk '{ print $NF ": " $5 }'

source

Find in Files

find . | xargs grep 'string' -sl

// or alternatively

find ./ -exec grep -Hn "YourString" {} ;

source

Linux Command for Listing all files which contains the word ‘abc’

find / -type f -exec grep -H 'abc' {} ;

source

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>

source

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>

source

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 />';
}

source

Search and replace through a whole directory tree

find . -type f -exec sed -i 's/STRING1/STRING2/' {} ;

source