find any occurance of a string in any file???

  • Permalink
  • submit to reddit
  • Email
  • Follow


I want to search all the files on my computer for the occurance of a 
particular string.  Before you blast me, I know, this seems silly.  But I 
have a reason.

I can use find ./ -name * to list all files, but how do I send them through 
a "grep" to find any occurance of, say, "poohead" within the files ????


Mairhtin O'Feannag

0
Reply irishboyca (42) 10/8/2003 9:25:48 PM

See related articles to this posting


On Wed, 08 Oct 2003 21:25:48 +0000, Mairhtin O'Feannag wrote:

> I want to search all the files on my computer for the occurance of a 
> particular string.  Before you blast me, I know, this seems silly.  But I 
> have a reason.
> 
> I can use find ./ -name * to list all files, but how do I send them through 
> a "grep" to find any occurance of, say, "poohead" within the files ????

find / -type f -exec grep -l poohead {} +

0
Reply daveuhring (1185) 10/8/2003 9:50:13 PM

On Wed, 08 Oct 2003 21:25:48 GMT, Mairhtin O'Feannag <irishboyca@rocketmail.com> wrote:
> 
> 
> I want to search all the files on my computer for the occurance of a 
> particular string.  Before you blast me, I know, this seems silly.  But I 
> have a reason.
> 
> I can use find ./ -name * to list all files, but how do I send them through 
> a "grep" to find any occurance of, say, "poohead" within the files ????
> 
> 
> Mairhtin O'Feannag
> 

If you have GNU grep, you can do:

grep -rs  'poolhead'  /   # the r means recursive and the s silences error
                          # messages 

If not, then try something like this:

find /  -type f  -exec  grep 'poolhead' {} \;

The {} refers to whatever file find is currently focussing on.


-- 
Later, Alan C
You can find my email address at the website: contact.html
take control of your mailbox ----- elrav1 ----- http://tinyurl.com/l55a
0
Reply zzzzzz (1966) 10/8/2003 9:59:12 PM

Mairhtin O'Feannag wrote:

> I want to search all the files on my computer for the occurance of a
> particular string.  Before you blast me, I know, this seems silly.  But I
> have a reason.
> 
> I can use find ./ -name * to list all files, but how do I send them
> through a "grep" to find any occurance of, say, "poohead" within the files
> ????

$ find . | xargs grep pattern

-- 
Paul Lutus
http://www.arachnoid.com

0
Reply nospam248 (2592) 10/8/2003 10:06:41 PM

Dave Uhring wrote:

> On Wed, 08 Oct 2003 21:25:48 +0000, Mairhtin O'Feannag wrote:
> 
>> I want to search all the files on my computer for the occurance of a
>> particular string.  Before you blast me, I know, this seems silly.  But I
>> have a reason.
>> 
>> I can use find ./ -name * to list all files, but how do I send them
>> through a "grep" to find any occurance of, say, "poohead" within the
>> files ????
> 
> find / -type f -exec grep -l poohead {} +

on my system you need to do:

find / -type f -exec grep -l poohead '{}' ';'

{} means the found file, ; is the delimiter for find -exec, and they both
need quoting.

andy.

-- 
remove 'n-u-l-l' to email me. html mail or attachments will go in the spam
bin unless notified with [html] or [attachment] in the subject line.
0
Reply news21 (108) 10/8/2003 10:07:30 PM

On Wed, 08 Oct 2003 16:50:13 -0500, Dave Uhring <daveuhring@yahoo.com> wrote:
> 
> 
> On Wed, 08 Oct 2003 21:25:48 +0000, Mairhtin O'Feannag wrote:
> 
>> I want to search all the files on my computer for the occurance of a 
>> particular string.  Before you blast me, I know, this seems silly.  But I 
>> have a reason.
>> 
>> I can use find ./ -name * to list all files, but how do I send them through 
>> a "grep" to find any occurance of, say, "poohead" within the files ????
> 
> find / -type f -exec grep -l poohead {} +
> 

Why the  + ?

The only possibly relevant reference to + in the find man page is:

-perm +mode
              Any of the permission bits mode  are  set  for  the
              file.

And it doesn't seem to be part of a regex for grep.... 


-- 
Later, Alan C
You can find my email address at the website: contact.html
take control of your mailbox ----- elrav1 ----- http://tinyurl.com/l55a
0
Reply zzzzzz (1966) 10/8/2003 10:19:12 PM

On Wed, 08 Oct 2003 22:19:12 +0000, Alan Connor wrote:

> Why the  + ?
> 
> The only possibly relevant reference to + in the find man page is:
> 
> -perm +mode
>               Any of the permission bits mode  are  set  for  the
>               file.
> 
> And it doesn't seem to be part of a regex for grep....

It came from Solaris.  I posted the wrong command ;-)

0
Reply daveuhring (1185) 10/8/2003 10:33:56 PM

On Wed, 08 Oct 2003 17:33:56 -0500, Dave Uhring <daveuhring@yahoo.com> wrote:
> 
> 
> On Wed, 08 Oct 2003 22:19:12 +0000, Alan Connor wrote:
> 
>> Why the  + ?
>> 
>> The only possibly relevant reference to + in the find man page is:
>> 
>> -perm +mode
>>               Any of the permission bits mode  are  set  for  the
>>               file.
>> 
>> And it doesn't seem to be part of a regex for grep....
> 
> It came from Solaris.  I posted the wrong command ;-)
> 

<chuckle>

Thanks.

-- 
Later, Alan C
You can find my email address at the website: contact.html
take control of your mailbox ----- elrav1 ----- http://tinyurl.com/l55a
0
Reply zzzzzz (1966) 10/8/2003 10:59:18 PM

On Wed, 08 Oct 2003 22:59:18 +0000, Alan Connor wrote:

> On Wed, 08 Oct 2003 17:33:56 -0500, Dave Uhring <daveuhring@yahoo.com> wrote:

>> It came from Solaris.  I posted the wrong command ;-)
>> 
> 
> <chuckle>
> 
> Thanks.

Solaris find(1):

     -exec command
           True if the executed command returns a zero  value  as
           exit  status. The end of command must be punctuated by
           an escaped semicolon (;). A  command  argument  {}  is
           replaced  by  the current path name. If the last argu-
           ment to -exec is {} and you specify + rather than  the
           semicolon  (;),  the  command  will  be  invoked fewer
           times, with {} replaced by groups of pathnames.

Makes the search run quicker.

0
Reply daveuhring (1185) 10/8/2003 11:25:33 PM

=2D----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

At 2003-10-08T22:06:41Z, Paul Lutus <nospam@nosite.zzz> writes:

> $ find . | xargs grep pattern

I second this.  It will be a huge win over the "find . -exec grep" syntax in
that it will spawn a vastly smaller number grep processes over the duration
of the run.
=2D --=20
Kirk Strauser
The Strauser Group
Open. Solutions. Simple.
http://www.strausergroup.com/
=2D----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQE/hKQo5sRg+Y0CpvERAurgAJ0XB8pDWsTT6Etuwfy9lyhRDAHkTwCfRLI4
spgHGqo4FzL+7uRGeWML+nk=3D
=3DqPBI
=2D----END PGP SIGNATURE-----
0
Reply kirk (233) 10/9/2003 12:00:19 AM

Mairhtin O'Feannag wrote:
> I can use find ./ -name * to list all files, but how do I send them through 
> a "grep" to find any occurance of, say, "poohead" within the files ????

$ find . -print0 | xargs -0 grep

The "-print0" arg to find and "-0" arg to xargs deal with files with
embedded newlines.

For more info on what xargs does, 
$ man xargs 

Ed

0
Reply news20 (49) 10/9/2003 12:45:25 AM

On Thu, 09 Oct 2003 00:00:19 GMT, Kirk Strauser <kirk@strauser.com> wrote:
> 
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> At 2003-10-08T22:06:41Z, Paul Lutus <nospam@nosite.zzz> writes:
> 
>> $ find . | xargs grep pattern
> 
> I second this.  It will be a huge win over the "find . -exec grep" syntax in
> that it will spawn a vastly smaller number grep processes over the duration
> of the run.
> - -- 
> Kirk Strauser
> The Strauser Group
> Open. Solutions. Simple.
> http://www.strausergroup.com/
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.3 (GNU/Linux)
> 
> iD8DBQE/hKQo5sRg+Y0CpvERAurgAJ0XB8pDWsTT6Etuwfy9lyhRDAHkTwCfRLI4
> spgHGqo4FzL+7uRGeWML+nk=
> =qPBI
> -----END PGP SIGNATURE-----


I like the xargs solution, but why do you have to get in our faces with the
PGP crap?

Do you have any idea how FEW people use it, and how FEW people give a
tinker's damn whether you are posting a message with a key registered to
the name Kirk Strauser?

You real name could be Gertrude Hoskenblatt, so what the hell is the point?

If you were communicating with your bank on a sensitive matter involving
patents and copyrights, I could see using PGP.

But HERE, we only care about the quality of our posts, and part of that
quality involves whether you clutter them with useless garbage or not.

It's nothing but a big, pretentious ego-trip.

(if it wasn't, you would put the info in your headers and refer to it in
a short line in your sig, like people with manners do)

Guess what? It is no harder to install PGP than it is to install a frigging
text editor, so I cannot imagine who the hell you think you are impressing.

You have a BIZARRE idea of what constitutes "Solutions" that are "Simple".

If I see the stupid PGP sig again, you are killfiled for 30 days.

(Or are you going to tell me that I have to install a different newsreader
that hides PGP sigs so that you can get some kind of neurotic satisfaction
from chronically advertising the fact that you use a program that most
people don't?)


-- 
Later, Alan C
You can find my email address at the website: contact.html
take control of your mailbox ----- elrav1 ----- http://tinyurl.com/l55a
0
Reply zzzzzz (1966) 10/9/2003 12:59:19 AM

On Wed, 08 Oct 2003 18:25:33 -0500, Dave Uhring <daveuhring@yahoo.com> wrote:
> 
> 
> On Wed, 08 Oct 2003 22:59:18 +0000, Alan Connor wrote:
> 
>> On Wed, 08 Oct 2003 17:33:56 -0500, Dave Uhring <daveuhring@yahoo.com> wrote:
> 
>>> It came from Solaris.  I posted the wrong command ;-)
>>> 
>> 
>> <chuckle>
>> 
>> Thanks.
> 
> Solaris find(1):
> 
>      -exec command
>            True if the executed command returns a zero  value  as
>            exit  status. The end of command must be punctuated by
>            an escaped semicolon (;). A  command  argument  {}  is
>            replaced  by  the current path name. If the last argu-
>            ment to -exec is {} and you specify + rather than  the
>            semicolon  (;),  the  command  will  be  invoked fewer
>            times, with {} replaced by groups of pathnames.
> 
> Makes the search run quicker.
> 

Ahh.

-- 
Later, Alan C
You can find my email address at the website: contact.html
take control of your mailbox ----- elrav1 ----- http://tinyurl.com/l55a
0
Reply zzzzzz (1966) 10/9/2003 12:59:20 AM

On Wed, 08 Oct 2003 21:59:12 GMT, Alan Connor <zzzzzz@xxx.yyy> wrote:
> On Wed, 08 Oct 2003 21:25:48 GMT, Mairhtin O'Feannag <irishboyca@rocketmail.com> wrote:
>> 
>> 
>> I want to search all the files on my computer for the occurance of a 
>> particular string.  Before you blast me, I know, this seems silly.  But I 
>> have a reason.
>> 
>> I can use find ./ -name * to list all files, but how do I send them through 
>> a "grep" to find any occurance of, say, "poohead" within the files ????
>> 
>> 
>> Mairhtin O'Feannag
>> 
> 
> If you have GNU grep, you can do:
> 
> grep -rs  'poolhead'  /   # the r means recursive and the s silences error
>                           # messages 
> 
> If not, then try something like this:
> 
> find /  -type f  -exec  grep 'poolhead' {} \;
> 
> The {} refers to whatever file find is currently focussing on.
> 
> 

I usually do it like this

find / -type f -exec grep 'poolhead' /dev/null \{\} \;

having two files in the arguments for grep will make grep print
out the file name it finds the string in.  Of course it'll never
find it in /dev/null  :)


0
Reply creideiki (13) 10/9/2003 1:59:22 AM

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Alan Connor wrote:
> I like the xargs solution, but why do you have to get in our faces with the
> PGP crap?
> 
> Do you have any idea how FEW people use it, and how FEW people give a
> tinker's damn whether you are posting a message with a key registered to
> the name Kirk Strauser?
> 
> You real name could be Gertrude Hoskenblatt, so what the hell is the point?
> 
> If you were communicating with your bank on a sensitive matter involving
> patents and copyrights, I could see using PGP.
> 
> But HERE, we only care about the quality of our posts, and part of that
> quality involves whether you clutter them with useless garbage or not.
> 
> It's nothing but a big, pretentious ego-trip.
> 
> (if it wasn't, you would put the info in your headers and refer to it in
> a short line in your sig, like people with manners do)
> 
> Guess what? It is no harder to install PGP than it is to install a frigging
> text editor, so I cannot imagine who the hell you think you are impressing.
> 
> You have a BIZARRE idea of what constitutes "Solutions" that are "Simple".
> 
> If I see the stupid PGP sig again, you are killfiled for 30 days.
> 
> (Or are you going to tell me that I have to install a different newsreader
> that hides PGP sigs so that you can get some kind of neurotic satisfaction
> from chronically advertising the fact that you use a program that most
> people don't?)

Nope, but do find a newsreader with decent filtering capabilities, and have it chuck out any message 
that begins with "BEGIN PGP SIGNED MESSAGE" in the first couple of lines.

I think that will make everyone happier :)

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE/hNMHeS99pGMif6wRAixfAJwJOmmP3qPmbfo5Bbp00g2yAniG+gCg1sxD
kSIFM+qiKQqgjHx6wzBmCHM=
=Rv4v
-----END PGP SIGNATURE-----

0
Reply spam405 (14) 10/9/2003 3:16:17 AM

On Thu, 09 Oct 2003 00:59:19 +0000, Alan Connor wrote:

> (Or are you going to tell me that I have to install a different newsreader
> that hides PGP sigs so that you can get some kind of neurotic satisfaction
> from chronically advertising the fact that you use a program that most
> people don't?)

Like you do with elrav1.  But you've killfiled me forever (didn't you once
claim that you never do that?); I'm writing this solely for the benefit of
the others reading the thread.

0
Reply emurphy42 (1226) 10/9/2003 4:58:01 AM

=2D----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

At 2003-10-09T01:59:22Z, Creideiki <creideiki@cfl.rr.com> writes:

> I usually do it like this
>
> find / -type f -exec grep 'poolhead' /dev/null \{\} \;
>
> having two files in the arguments for grep will make grep print out the
> file name it finds the string in.  Of course it'll never find it in
> /dev/null :)

So will the '-l' option to grep:

    $ grep -l foo test.mail
    test.mail

And in any case you really want to use xargs instead of -exec .
=2D --=20
Kirk Strauser
The Strauser Group
Open. Solutions. Simple.
http://www.strausergroup.com/
=2D----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQE/hUp95sRg+Y0CpvERAo7WAJwPfGEk2rPQSq7NqtGE/ZFSF/x8aACePF3q
4nCxH0nDdyfvGmyXETMpUEA=3D
=3DWqZe
=2D----END PGP SIGNATURE-----
0
Reply kirk (233) 10/9/2003 11:50:06 AM

[This followup was posted to comp.os.linux.misc]

In article <Xns940E92E72FD06mairhtinofeannag@64.164.98.49>, 
irishboyca@rocketmail.com says...
> I want to search all the files on my computer for the occurance of a 
> particular string.  Before you blast me, I know, this seems silly.  But I 
> have a reason.
> 
> I can use find ./ -name * to list all files, but how do I send them through 
> a "grep" to find any occurance of, say, "poohead" within the files ????
> 
> 
> Mairhtin O'Feannag

find ./ -name '*' -exec fgrep poolhead /dev/null '{}' \;
0
Reply raisin3 (35) 10/9/2003 1:18:41 PM

That would be "poohead", not "poolhead".   Giggle

It's interesting to me STILL that flame wars can occur in such a 
simple/direct thread.  :)

I used the xargs solution.  Seems to work.  I've come across it before, 
and had simply forgotten it.  Have to write these things down, now that 
I'm old and feeble (NOT!).  

Thanks for all the prompt and helpful responses folks!!!!

M


Barry Kimelman <raisin@delete-this-trash.mts.net> wrote in
news:MPG.19ef1c266d8eeca898969b@news.mts.net: 

> [This followup was posted to comp.os.linux.misc]
> 
> In article <Xns940E92E72FD06mairhtinofeannag@64.164.98.49>, 
> irishboyca@rocketmail.com says...
>> I want to search all the files on my computer for the occurance of a 
>> particular string.  Before you blast me, I know, this seems silly. 
>> But I have a reason.
>> 
>> I can use find ./ -name * to list all files, but how do I send them
>> through a "grep" to find any occurance of, say, "poohead" within the
>> files ???? 
>> 
>> 
>> Mairhtin O'Feannag
> 
> find ./ -name '*' -exec fgrep poolhead /dev/null '{}' \;
> 

0
Reply irishboyca (42) 10/9/2003 4:57:00 PM

On Wed, 08 Oct 2003 21:25:48 +0000, Mairhtin O'Feannag wrote:

> I want to search all the files on my computer for the occurance of a
> particular string.  Before you blast me, I know, this seems silly.  But I
> have a reason.
> 
> I can use find ./ -name * to list all files, but how do I send them
> through a "grep" to find any occurance of, say, "poohead" within the files
> ????
> 
> 
> Mairhtin O'Feannag
grep -R poohead ./*
0
Reply no_mail4391 (2) 10/9/2003 7:12:45 PM

On Thu, 09 Oct 2003 11:50:06 GMT, Kirk Strauser <kirk@strauser.com> wrote:
> At 2003-10-09T01:59:22Z, Creideiki <creideiki@cfl.rr.com> writes:
> 
>> I usually do it like this
>>
>> find / -type f -exec grep 'poolhead' /dev/null \{\} \;
>>
>> having two files in the arguments for grep will make grep print out the
>> file name it finds the string in.  Of course it'll never find it in
>> /dev/null :)
> 
> So will the '-l' option to grep:
> 
>     $ grep -l foo test.mail
>     test.mail
> 
> And in any case you really want to use xargs instead of -exec .

Yeah, I hadn't known of xargs before now.

But what I was doing with the double file name was make the
find -exec grep act like grep with globbing, where it prints
the name of the file it finds the regular expression *and* prints
the line that matched it.  -l only prints the name.


     $ grep  foo /dev/null test.mail
     test.mail:someline with the string 'foo' in it


0
Reply creideiki (13) 10/9/2003 7:45:18 PM

=2D----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

At 2003-10-09T19:45:18Z, Creideiki <creideiki@cfl.rr.com> writes:

> But what I was doing with the double file name was make the find -exec
> grep act like grep with globbing, where it prints the name of the file it
> finds the regular expression *and* prints the line that matched it.  -l
> only prints the name.

Oh!  Like the "-H" flag to GNU grep:

    $ grep -H tells wi.4
    wi.4:This tells the pccard system to use PCI interrupts for this odd be=
ast.

=2D --=20
Kirk Strauser
The Strauser Group
Open. Solutions. Simple.
http://www.strausergroup.com/
=2D----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQE/hb2i5sRg+Y0CpvERAnvsAJ9QSJ2JB9BYCBPwjpwQzssZwHIB5ACgkdLk
H0kl6jpgFiSNNh8d64+UipQ=3D
=3D80E/
=2D----END PGP SIGNATURE-----
0
Reply kirk (233) 10/9/2003 8:00:07 PM

> I want to search all the files on my computer for the occurance of a 
> particular string.  

The use of `exec` is one way to do this, but another is this:

find / -type f | xargs grep something

Xargs is one of the *very* cool commands that isn't used as much as it
should be (see lsof).  I am just learning it myself actually.  The
thing about xargs is that the command that comes after it is treated
as if it's being piped to.  So xargs builds a list of input from what
came before it, and then does the command that comes after it for each
item in that list.

You could, for example, find all files owned by a certain person, and
copy them to a directory, etc.

Enjoy.

-danielrm26
0
Reply danielrm26 (8) 10/10/2003 1:22:32 AM
comp.os.linux.misc 33410 articles. 19 followers. Post

22 Replies
122 Views

Similar Articles

[PageSpeed] 49


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

Find strings in one file that are not in other file
Suppose I have two files N.txt and O.txt .N contains unique strings that are sorted alphabetically .Similarly O also contains unique strings that are sorted alphabetically . I want to find those strings that are in N.txt but not in O.txt .The condition is that both N and O.txt are very long files and contain only 1 string per line.How can this be done in the most shortest/efficient way??(unix/linux commands ) "jeniffer" <zenith.of.perfection@gmail.com> writes: > Suppose I have two files N.txt and O.txt .N contains unique strings > that are sorted alphabetically .Simila...

Find All only finds in open files if search string contains \n
Found this while running CW 8.3 (IDE v5.1.1 Build 1108) under Mac OS X 10.3.5 on a Quicksilver 2002 G4. The project (Adobe InDesign sample plugin "SnippetRunner" from the InDesign CS 3.01 SDK) has 98 source files and 6 library files. Source files use Unix line end ('\n'). When I did "Find All" for search strings such as "\n(" or "\n:" the search would fail unless the file(s) containing those string were open in the IDE. Not fatal but damn annoying. Anyone else see things like this? In article <steve-F20532.15014919082004@new...

open a text, find a string, and delete everything before this string, resave file.
Hello all, I'm sure this is an easy question. I have a text file with a bunch of variables set into it. I would like to load this file and run it as an .m file so that each of these strings are evaluated in matlab, this is no problem, I can open the file, and save it as an .m file. My problem is that each of the text files has a random number of header lines, that I want to get rid of, this would be easy if the number of headers in each of my files were the same, but it is not. However, the starting point is always the same. So i want to open a text file, and find where it says "m_...

find string in file
Hi, Is there in Xharbour a function to find a string like "glass*" in a file and filter it or create a new file with the found records ? Jos On 31 Gen, 22:56, "J Cuypers" <jos.cuyp...@telenet.be> wrote: > Hi, > Is there in Xharbour a function to find a string like "glass*" in a file and > filter it or create a new file with the found records ? > > Jos UNTESTED use yourdbf COPY FIELDS code,desc FOR "GLASS"$ Upper(desc) TO file.Tmp SDF YOU CAN USE ALSO DELIMITED WITH INSTEAD sdf Did you think about somethi...

finding a string in a file
If I were trying to find a string like 'sql' in a file how would I execute that command from the telnet prompt? Any help appreciated. Mike Michael Hill <hillmw@ram.lmtas.lmco.com> wrote: > If I were trying to find a string like 'sql' in a file how would I > execute that command from the telnet prompt? grep sql nameofthefile man grep for more info Davide -- | The road to hell is paved with good intentions. And littered with | sloppy analysis! | | Davide Bianchi wrote: > > If I were trying to find a string like 'sql' in a file how would I &...

find string between files
Hi all, how can I search for a specific string inside a directory (between files) ? Thanks for your help "e.group" wrote: > how can I search for a specific string inside a directory (between files) ? Strings between files? Can you be any more obscure? -am � 2003 Anthony Mandic <r2@hotmail.com> wrote: > "e.group" wrote: > > > how can I search for a specific string inside a directory (between files) ? > > Strings between files? Can you be any more obscure? Yes, he could have posted it in Hebrew. ...

find string in file
Dear all, I have several files containing just one line and each line contains different characters separated by blank spaces: xxxxx/xxx --xx xx --xx xx xxxx xxx xxxx xx/xxxx/x.yyy let say that I would like just to retrieve strings that match the pattern "*yyy", the output should be: xx/xxxx/x.yyy If I do a grep, the whole line is retrieved. How could I retrieve just a single string? Best wishes On Mon, 10 May 2010 06:11:55 -0700 (PDT), Javier Montoya wrote: > Dear all, > > I have several files containing just one line and each line contains > diff...

find string in files
Hello, Can someone give me a simple shell script that search for a specific string in all files ? Same as MS Windows' "Search/Find in file" functionality. Regards, Elias lallous typed (on Fri, Jul 25, 2003 at 11:47:07AM -0700): | | Can someone give me a simple shell script that search for a specific | string in all files ? find / -type f | xargs grep "specific string" /dev/null | less -- JP lallous typed (on Tue, Aug 05, 2003 at 12:23:40AM +0300): | thanks JP, it works. | | can you dissect and explain it please ? Perhaps you have noticed another thread over th...

find a string in files
Hi $ grep -FHrn string /path/ will find occurrences of the string in files recursively, but will also find "stringing" and "strings". how can I limit it to only "string" thanks Gary Wessle wrote: > Hi > $ grep -FHrn string /path/ > will find occurrences of the string in files recursively, but will > also find "stringing" and "strings". > how can I limit it to only "string" > grep -FHwire string /path/ > thanks np P.S.: It's called a word boundary. HTH, -- Stephan Grein, <stephan at stephan mi...

find string in file
Hi friends !! I'm neophite about python, my target is to create a programa that find a specific string in text file. How can do it? Thanks fel On 14 mar, 14:25, fminerv...@gmail.com wrote: > Hi friends !! > > I'm neophite about python, my target is to create a programa that > find a specific string in text file. > How can do it? > > Thanks > fel $ cat text.txt aaa bbb ccc ddd aaa bbb ccc ddd aaa bbb ccc ddd aaa eee bbb eee ccc eee ddd eee $ cat bin/find_string.py import sys file_name=sys.argv[1] searched_string=sys.argv[2] result= [(line_number+1, line) fo...

Script to move files with one occurence of a string to one directory, and other files to another directory?
I could use a script for the bash shell to look through a group of files (s= elected from one directory by a wildcard expression) and move any of those = files with exactly one occurrence of the string Path: to a different direct= ory, usually a subdirectory of the first directory. The rest of the files = selected by the wildcard expression are move to a third directory, also usu= ally a subdirectory of the first directory. I'm currently doing this manua= lly, but with grep commands to count the number of occurrences. NOT homework - I'm retired. Actually using Cygwin (an em...

Trying to find shell script that will find all files which contains string "os_release ?.11.23" and replace it with "os_release ?.11.*"
Hi! Like i said above in subject ... can anyone help me? I want to find all files which contain(s) string in file and replace it with another string ... EX: Let's i want to change all files in /tmp dir which contain(s) string "my first shell script" with "my second shell script" Brgds, Sero Shit :) One more time :)) EX: Let's say that i want to change all files in /tmp dir which contain(s) string "my first shell script" and replace it with "my second shell script" Any clues? Brgds, Sero sergejk wrote: > Shit :) > > One more...

Finding a string in a file #2
Hi: I need search a specified string in a file, after the word "mounting" , like this: solaris> cat file netbackup, orac_ux001 backup, streaming yes, multiplexing ok , mounting M00541 police enabled, data file Which awk command can I issue to extract only the "M00541" string inside a file ? Thanks On May 28, 2:52 pm, apogeusiste...@gmail.com wrote: > Hi: > I need search a specified string in a file, after the word > "mounting" , like this: > > solaris> cat file > netbackup, orac_ux001 backup, streaming yes, multiplexing ok , > mount...

find a string in path/files
Hi I have a directory with lots of html files, I need to search all the files under that dir/path for a string and display the results, I usually do that with $grep -FHrn string /path/ 2 problems, the files are html, I can convert them if I need to. the files contain c++ code, and I like to display the block of text where the search string is found, any idea? thanks On 06 Aug 2006 03:01:43 +1000, Gary Wessle <phddas@yahoo.com> wrote: > Hi > > I have a directory with lots of html files, I need to search all the > files under that dir/path for a string and display the r...

Finding length of string on in file
I am not sure where to start with this one. I have a files with records like the following title ( names, spaces #s) name1 "bunch of stuff , ticks, spaces backslashes" <- all in between the quotes description "A bunch of text data " <- some beyond 64 bytes some less than 64 bytes name2 name3 name4 blank line new record here blank line new record here I want to find all records where the description has more than 64bytes in between the quotes. I then want to take those records, keep the title line and description and remove the other lines. then end result...

Re: finding a string in a file
In article <>, Michael Hill <hillmw@ram.lmtas.lmco.com> wrote: > > Bob Hauck wrote: > > > > > > You want to get a list of all files that contain the string 'sql' in the > > current directory or any subdirectory? Try this: > > > > find . -type f -exec grep -l 'sql' {} \; > > > Michael Hill wrote: > This worked .... > > > But this is faster because it doesn't spawn a grep for each file: > > > > find . -type f | xargs grep -l 'sql' > > > > Yes, this was fast...

finding files with certain strings
I have a listing of filenames from the dir command. I have already removed the '.' and '..' entries using: files = files(arrayfun(@(x)x.name(1), files) ~= '.') I am trying to retrieve the filenames that have for example 'myfile' somewhere in the filename. Any ideas without resorting to a loop and using one of findstr commands? Thanks! On 4 Sep, 17:20, "David " <david.shuttlewo...@navy.mil> wrote: > I have a listing of filenames from the dir command. =A0I have already rem= oved the '.' and '..' entries using: > > fil...

find string in a text file
hi guys, First thanks for the support in my last question posted here. Now i have been trying today to read about finding a way to solve this (simple?) problem....which is...i have a string lets say "Leila" from user and i want to search a text file with a table of values "name of girl" "hair color", so like this somehow: Leila black Sabrina blonde Sheila black .. .. etc... Now i want to get the value of the "hair color" and do something with it....printf-it or whatever...what is the most memory effective way to do so?is it with awk and grep and stu...

Finding strings in binary files
Hello everyone, I wrote, simply as an exercise, a small piece of code to find 'strings' (defined as an amount of at least 3 ASCII characters followed by a non ASCII character) in binary files. The purpose of the program is to serve as a facile 'strings' (Unix command) replacement and to be 100% ANSI C. Unfortunatelly it operates notedly slower than the original 'strings' from the fileutils package. Maybe someone has some hints on how to improve performance and keep the code at the same time pure ANSI C. Any other remarks to obvoius or not so obvoius errors are hig...

How find and replace a string in the HTML file
hi gurus I need to replace some string in the html file but haven't manage to work it out. In a HTML file I have a string : ......<a href="javascript:CreateList(TopForm)"><img src="images/playselected.gif" bgcolor="#949494" align="right/" border="0"></a> .... Which I need to replace with this one: &nbsp; I have look for exsample HTML::Parser but couldn't understand how it works !! So please, give me exsample code how to find a string and replace it. Thanks advance -Jussi > hi gurus > > I need ...

find a string pattern in files and replace it
Hi, I searched a file system and found a string pattern in several files. I want to change that string to other string. Can anyone shed some light on how to do it. Thanks in advance. Mike Mike wrote: > Hi, > I searched a file system and found a string pattern in several files. I > want to change that string to other string. Can anyone shed some light > on how to do it. > Thanks in advance. > Mike > #!/bin/sh pattern="foo" replacement="bar" find . -exec grep -l "$pattern" {} \; | while read file do echo "replacing $pattern by $replac...

Re: finding a string in a file #2
Ed Murphy <emurphy42@socal.rr.com> wrote: > On Mon, 19 Apr 2004 01:33:30 -0500, not wrote: > > >> > find . -type f | xargs grep -l 'sql' > > > Unless you're a student who has the 'task' of 'learning' the syntax > > of "find", this is a wastefull as learing 29-digit telephone numbers. > > > > I search for strings in dir-trees 4 times a day, and don't WANT to > > know the syntax of "find". > > Oh, c'mon, there's not *that* much syntax. The usual command for > find-...

Finding files which does not contain a specific string
I am trying to search a string amongst the files using ksh> grep "string" files* gives files which contains that "string" But I really want a list of files which does NOT contain the "string" grep -L "string" files* does not work, it is GNU grep I am using HP/unix ksh , I can switch to csh or zsh help would be appreciated thanks in advance rash wrote: > I am trying to search a string amongst the files > > using > ksh> grep "string" files* > > gives files which contains that "string" > But I r...

Program to find occurences of a word in a file
Hello For one of the interviews I took recently, I was given an offline programming quiz. In 30 minutes I had to write code in C++ to counts the number of times each unique word appears in a given file. I tried my level best even after the quiz to come up with a solution but cudnt find an efficient one. :( This is what I did. 1. Read all the words from the file and store them in a vector container. 2. Sort the words in the vector container using most efficient algorithm ( like Quicksort, Mergesort etc) 3. Then finding duplicates and occurences is very easy. I was asked to do this without so...