grep command and the find command
Commands to type[]
- find . -exec grep -l "tosearch" {} \; 2> /dev/null
- find . -name "*.txt" -type f -exec grep -l "tosearch" {} \; 2> /dev/null
Commands to type if you want to ignore the file type[]
- grep -r "tosearch"
A simple script[]
You can use the following simple script named grind (grep + find):
#!/usr/bin/env perl $arg = $ARGV[0]; $typ = $ARGV[1]; if ($typ eq "") {$typ = "*"}; print("\n***************\"$arg\" in files \"$typ\"****************\n"); $txt = "find . -name \"$typ\" -type f -exec grep -l \"$arg\" {} \\; 2> /dev/null"; system("$txt"); print("\n");
Then you can use 'grind name "*.cpp"' to see all files . cpp that contain name. (a few bugs remain in the script)
From HowTo Wiki, a Wikia wiki.