2008/11/21 Jobst Schmalenbach [EMAIL PROTECTED]:
Hi.
I beg to differ.
1: its quicker to type fstr HTML '*.php'
It's shorter to define:
function fstr() { grep -r --colour=always --include=${2:-*} $1 . | less -R; }
If you insist on using fstr :)
2: less (and more) kill the highlighting
Hi.
I beg to differ.
1: its quicker to type fstr HTML '*.php'
2: less (and more) kill the highlighting done by grep
3: grep has to (internally) call the other processes to to the same I am
already doing with pipes
4: (overly pedantic): can do more with find grep can ever do and I can
quote who=Jobst Schmalenbach
2: less (and more) kill the highlighting done by grep
Use less -R and *never* use more!
3: grep has to (internally) call the other processes to to the same I am
already doing with pipes
No, there's a massive difference between syscalls and forking processes.
Put this into your .bashrc file:
function fstr()
{
OPTIND=1
local case=
local usage=fstr: find string in files.\nUsage: fstr [-i] \pattern\
[\filename pattern\]
while getopts :it opt
do
case $opt in
i) case=-i ;;
*) echo $usage; return;;
2008/11/17 Jobst Schmalenbach [EMAIL PROTECTED]:
Put this into your .bashrc file:
function fstr()
{
OPTIND=1
local case=
local usage=fstr: find string in files.\nUsage: fstr [-i] \pattern\
[\filename pattern\]
while getopts :it opt
...
find . -type f -name ${2:-*}
Is there a command that finds a file containing a certain word?
find and apropos don't. They work on filenames only.
Using Hardy H.
Any suggestions gratefully etc.
Bill Bennett
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs:
quote who=[EMAIL PROTECTED]
Is there a command that finds a file containing a certain word?
find and apropos don't. They work on filenames only.
grep ... and you can use -r to search through files/directories recursively.
- Jeff
--
Robot Parade
Jeff Waugh wrote:
quote who=[EMAIL PROTECTED]
Is there a command that finds a file containing a certain word?
find and apropos don't. They work on filenames only.
grep ... and you can use -r to search through files/directories recursively.
You can also use -i to do a case insensitive
find . -exec grep www.athabasca '{}' \; -print
This command will search in the current directory and all sub directories.
All files that contain the string will have their path printed to standard
output.
If you want to just find each file then pass it on for processing use the -q
grep option.
quote who=Mada R Perdhana
find . -exec grep www.athabasca '{}' \; -print
This is massively inefficient. A better choice would be grep -rl piped to
xargs.
grep -rl www.athabasca | xargs sed -i 's#www.athabasca#www.bathsheba#'
- Jeff
--
OSDC 2008: Sydney, Australia
[EMAIL PROTECTED] wrote:
Is there a command that finds a file containing a certain word?
find and apropos don't. They work on filenames only.
Using Hardy H.
Any suggestions gratefully etc.
Bill Bennett
Hello Bill,
find . -name * -print -exec grep word {} \;
finds the word word in files
11 matches
Mail list logo