|
Home > Archive > Unix Shell > November 2005 > help using find on linux
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
help using find on linux
|
|
| Petterson Mikael 2005-11-24, 7:48 am |
| Hi,
I am trying to use find on my linux box. I seem to have a problem with
soft links since I cannot find any Java files containing sleep ( I know
there is .....).
From my current directory I have the following stucture:
pwd
..
cd src/se/company/radio/tbds/mxx/
common@ fpx@ main@ mao@ pms@
find . -name '*.java' -follow -print -exec grep -l 'sleep' {}\;
When I do find I don't see the command printing out the files it is
searching for sleep in. Also it does not seem to follow my soft links.
Any hints?
cheers,
//mikael
| |
| Dan Mercer 2005-11-24, 5:54 pm |
|
"Petterson Mikael" <mikael.petterson@era.ericsson.se> wrote in message news:dm41lv$jt3$1@news.al.sw.ericsson.se...
: Hi,
:
: I am trying to use find on my linux box. I seem to have a problem with
: soft links since I cannot find any Java files containing sleep ( I know
: there is .....).
:
: From my current directory I have the following stucture:
:
: pwd
: .
: cd src/se/company/radio/tbds/mxx/
: common@ fpx@ main@ mao@ pms@
:
:
: find . -name '*.java' -follow -print -exec grep -l 'sleep' {}\;
This should give you an error message - are you redirecting standard
error perchance? {} and \; (which will be seen by find as just ";")
must be separate tokens - your last token is "{};" (as seen by find)
It should complain that -exec is not terminated.
Dan Mercer
:
: When I do find I don't see the command printing out the files it is
: searching for sleep in. Also it does not seem to follow my soft links.
:
: Any hints?
:
: cheers,
:
: //mikael
| |
| xicheng 2005-11-24, 5:54 pm |
| Hi, Petterson:
coz your softlinks don't have ".java" file extension, so you can not
use find -name "*.java" to grab them out. you should have to consider
them separately, like:
find -type f -name "*.java" -o -type l
use "-o" option to grab any file matching *.java or being a symbolic
link. then use "xargs" and "grep" to filter out your results.
find . \( -type f -name "*.java" -o -type l \) -print0 | xargs -0r
grep -l "sleep"
Hope this helps,
XC
Petterson Mikael wrote:
> Hi,
>
> I am trying to use find on my linux box. I seem to have a problem with
> soft links since I cannot find any Java files containing sleep ( I know
> there is .....).
>
> From my current directory I have the following stucture:
>
> pwd
> .
> cd src/se/company/radio/tbds/mxx/
> common@ fpx@ main@ mao@ pms@
>
>
> find . -name '*.java' -follow -print -exec grep -l 'sleep' {}\;
>
> When I do find I don't see the command printing out the files it is
> searching for sleep in. Also it does not seem to follow my soft links.
>
> Any hints?
>
> cheers,
>
> //mikael
| |
| Bill Seivert 2005-11-26, 2:50 am |
|
Petterson Mikael wrote:
> Hi,
>
> I am trying to use find on my linux box. I seem to have a problem with
> soft links since I cannot find any Java files containing sleep ( I know
> there is .....).
>
> From my current directory I have the following stucture:
>
> pwd
> .
> cd src/se/company/radio/tbds/mxx/
> common@ fpx@ main@ mao@ pms@
>
>
> find . -name '*.java' -follow -print -exec grep -l 'sleep' {}\;
As written, this will only follow a link where the link name ends in
..java
If the name doesn't end in .java, it is skipped without seeing the
-follow.
>
> When I do find I don't see the command printing out the files it is
> searching for sleep in. Also it does not seem to follow my soft links.
>
> Any hints?
>
> cheers,
>
> //mikael
find usually works better when -follow is the first operand,
also put a space between the {} and \;
find . -follow -name "*.java" -print -exec grep -l sleep {} \;
Bill Seivert
|
|
|
|
|