Re: Command to find execute file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I can never remember all the right commands to find so I wrote a script that
I put in the path somewhere like /usr/bin:

# findit - find file name and print

# check for arguments
if [ $1 ]; then
        a=a
else
        echo usage: findit search_string [starting_directory]
        exit
fi

# help
case $1 in
        -help | -h | -HELP ) echo usage: findit search_string
[starting_directory]; exit ;;
esac

# set directory (default to current)
if [ $2 ]; then
cd $2
echo starting in directory: $2
else
echo "starting in current directory: `pwd`"
fi

find . -iname $1 -print | more



I'm not much of a script writer, so there's probably a cleaner way to do it,
but it does what I need. It is kind of slow, I'm glad to learn the "locate"
command.

Joe D. Trent
Bigham Brothers, Inc.
Lubbock, Texas

Toll Free (U.S.): (800) 692-4449
(806) 745-0384
jtrent@xxxxxxxxxxxxxxxxxx
www.bighambrothers.com
----- Original Message -----
From: "Hattie Rouge" <redhat@xxxxxxxxxx>
To: <psyche-list@xxxxxxxxxx>
Sent: Friday, May 09, 2003 12:00 PM
Subject: RE: Command to find execute file


> FYI
>
> Commands like 'type' or 'which' or 'where' will search the PATH variable
> for a file.  Since this is supposed to be only executables, it is
> usually termed "search for executables" but it finds links to executable
> files so I don't think its that smart.  I think it will find any
> matching file in the PATH.
>
> Commands like 'find' actually walk the directory hierarchy looking for
> files so you can search all the disks if you want.  If you have
> permissions for it.  And it can be very slow to walk a large set of
> disks on a busy server.
>
> Last thing:
>
> find / -name *evolution*
>
> will not always work because in some cases the shell will see the splat
> (asterisk) and use it up instead of passing it on to the find program.
> Plus all the non-Linux Unices I've worked with don't assume a print
> sub-command.  So the more general purpose way to do this search is to
> escape any special characters you use just in case and explicitly
> request output.  So the above turns into:
>
> find / -name \*evolution\* -print
>
> Hope this helps.
>
>
> Hattie Rouge
>
>
> > -----Original Message-----
> > From: psyche-list-admin@xxxxxxxxxx
> > [mailto:psyche-list-admin@xxxxxxxxxx] On Behalf Of Stéphan Hemmert
> > Sent: Friday, May 09, 2003 5:07 AM
> > To: psyche-list@xxxxxxxxxx
> > Subject: Re: Command to find execute file
> >
> >
> > also another way to find a file:
> > find / -name *evolution*
> >
> > will scan the whole filesystem to find files which name contains
> > evolution ( can be pretty long)
> >
> > k.
> >
> > Stephen Liu wrote:
> >
> > >Hi all folks
> > >
> > >What command line will be used to find the execute file of a
> > software,
> > >e.g.
> > >
> > >/usr/bin/evolution
> > >
> > >the execute file of Ximian Evolution is under /usr/bin/  How
> > to locate
> > >it.
> > >
> > >Thanks in advance.
> > >
> > >B.Regards
> > >Stephen Liu
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> >
> >
> >
> >
> > --
> > Psyche-list mailing list
> > Psyche-list@xxxxxxxxxx
> > https://listman.redhat.com/mailman/listinfo/ps> yche-list
> >
>
>
>
> --
> Psyche-list mailing list
> Psyche-list@xxxxxxxxxx
> https://listman.redhat.com/mailman/listinfo/psyche-list
>



-- 
Psyche-list mailing list
Psyche-list@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/psyche-list

[Index of Archives]     [Fedora General Discussion]     [Red Hat General Discussion]     [Centos]     [Kernel]     [Red Hat Install]     [Red Hat Watch]     [Red Hat Development]     [Red Hat 9]     [Gimp]     [Yosemite News]

  Powered by Linux