Re: problems with FIND cmd

From: Barry Margolin (barmar_at_alum.mit.edu)
Date: 04/30/04


Date: Thu, 29 Apr 2004 20:31:32 -0400

In article <c6rte0$qfs$1@pcls3.std.com>,
 demas@TheWorld.com (Charles Demas) wrote:

> In article <a8970d9b.0404291129.52ba145e@posting.google.com>,
> DJE <david.ehresmann@ps.net> wrote:
> >How do I restrict the output of the find command to just the file
> >name?
>
> pipe find's output through basename?

I don't think you understood the question. The problem isn't the
directory portion of the filename, the problem is that the output
contains two names, "." and "./test".

I suspect the solution is to use -type f in the find options, to keep it
from showing directories.

>
>
> Chuck Demas
>
> >Here is the code:
> >
> >thefile=$(find . -newer trace_file_tmp -print)
> > if [ -n "$thefile" ] ; then
> > do something
> > fi
> >
> >Here is the directory it is operating in:
> >
> >-rwxr-xr-x 1 oracle dba 611 Apr 9 11:16
> >ora_19842_elmcig76.trc
> >-rw-r--r-- 1 oracle dba 0 Apr 29 14:18 test
> >-rw-r--r-- 1 oracle dba 0 Apr 28 14:12 trace_file_tmp
> >
> >
> >With this code I am getting $thefile shown in debug mode:
> >
> >thefile=.
> >./test
> >+ [ -n .
> >./test ]
> >
> >
> >With $thefile set to . or ./test it is not working like I need it.
> >How do I restrict find to only "test"?
> >Any suggestion will be appreciated.
> >
> >thanks,
> >
> >DJE

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


Relevant Pages

  • Re: duplicate in command line
    ... Charles Demas wrote: ... >>Is there any way to enter this command with duplicating the file name, ... >create your own alias or function. ...
    (comp.unix.shell)
  • Re: Multiple lines
    ... Charles Demas wrote: ... I am using a script file, so I broke up your command ...
    (comp.unix.shell)