how to find out all files or folders which has space in the name, andincludes specific string recursively?

This is a discussion on how to find out all files or folders which has space in the name, andincludes specific string recursively? within the Linux General forums, part of the Linux Forums category; suppose there are some folders and files in folder /tmp/noname.com like /tmp/noname.com/html/School Photos/help ...


Go Back   Usenet Forums > Linux Forums > Linux General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-25-2008
mike-yue
 
Posts: n/a
Default how to find out all files or folders which has space in the name, andincludes specific string recursively?

suppose there are some folders and files in folder /tmp/noname.com
like
/tmp/noname.com/html/School Photos/help me.html
/tmp/noname.com/www bak/html/cam/pics/many thanks.html
/tmp/noname.com/test/old test/god bless us.html
......

some of the files have a line including "global warming", like
...
we all know global warming, blah, blah
...

My shell script could not treat the spaces well, and I don't know how
to handle it.
Any hints would be appreciated!!
Reply With Quote
  #2 (permalink)  
Old 04-25-2008
Bill Marcum
 
Posts: n/a
Default Re: how to find out all files or folders which has space in the name, and includes specific string recursively?

On 2008-04-24, mike-yue <needpassion@gmail.com> wrote:
>
>
> suppose there are some folders and files in folder /tmp/noname.com
> like
> /tmp/noname.com/html/School Photos/help me.html
> /tmp/noname.com/www bak/html/cam/pics/many thanks.html
> /tmp/noname.com/test/old test/god bless us.html
> ......
>
> some of the files have a line including "global warming", like
> ...
> we all know global warming, blah, blah
> ...
>
> My shell script could not treat the spaces well, and I don't know how
> to handle it.
> Any hints would be appreciated!!


find . -name '* *' -print0 | xargs -0 grep "global warming"
Reply With Quote
  #3 (permalink)  
Old 04-25-2008
Sam
 
Posts: n/a
Default Re: how to find out all files or folders which has space in thename, and includes specific string recursively?

mike-yue writes:

> suppose there are some folders and files in folder /tmp/noname.com
> like
> /tmp/noname.com/html/School Photos/help me.html
> /tmp/noname.com/www bak/html/cam/pics/many thanks.html
> /tmp/noname.com/test/old test/god bless us.html
> ......
>
> some of the files have a line including "global warming", like
> ...
> we all know global warming, blah, blah
> ...
>
> My shell script could not treat the spaces well, and I don't know how
> to handle it.
> Any hints would be appreciated!!


find $PATHNAME -type f -name '* *' -print | xargs grep 'global warming hoax'


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQBIERoMx9p3GYHlUOIRApjQAJ4pLD3R9LHStJ1oE9Hj9Z icnY1tawCfVDUR
JiB275GJbrYeQeeZddKiUNU=
=Z2IC
-----END PGP SIGNATURE-----

Reply With Quote
  #4 (permalink)  
Old 04-25-2008
mike-yue
 
Posts: n/a
Default Re: how to find out all files or folders which has space in the name,and includes specific string recursively?

Bill, Sam,

You guys are really good.
I am not familiar with xargs, so xargs totally solved my problem.

Thank you guys!
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 09:24 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0