[Novalug] should be easy...

Jon LaBadie novalugml at jgcomp.com
Mon Nov 9 02:06:35 EST 2009


On Sun, Nov 08, 2009 at 10:13:51PM -0500, Jay Berkenbilt wrote:
> Nino Pereira <pereira at speakeasy.net> wrote:
> 
> > I can't seem to find the options on 'find' to give
> > me the full path to a file. In my home directory I use
> >
> > find -name '*part-of-filename-I-remember*'
> >
> > and I get
> >
> > ./the-right-filename-I-was-looking-for
> >
> > but not the directory it's in.
> 

The original find would not let you get away with
two added defaults in the gnu-find.  First if you
failed to specify an action, eg. -print or -exec,
find would locate your files but not tell you 
anything about them :)

Second, it would have complained if you did not specify
a starting directory or directories before the first
option, eg. "find /home/pereira /etc -name ...".
Now find defaults an unspecified starting directory to
".", the current directory.  Thus your output shows "."
as the path prefix.

> If you get this, then it's in the current directory.  Find always gives
> you the path of the file relative to anything you specified.
> 
> find ~ -name '*part-of-filename-I-remember*'
> 
> would give you the full path.

Everyone seems to assume that Nino is issuing his find
command from his home directory and thus are suggesting
"find ~ ..." where "~" expands to the same value as $HOME.

A better suggestion would be "find ~+ ..." as "~+" expands
to the same value as $PWD, the full path to the present
working directory.  If that happens to be the Nino's home
directory, then $HOME, ~, and ~+ would all be the same.

BTW for completeness, "~-" expands to the full path of
your previous directory, the same value as $OLDPWD.

-- 
Jon H. LaBadie                  jon at jgcomp.com
 JG Computing
 12027 Creekbend Drive		(703) 787-0884
 Reston, VA  20194		(703) 787-0922 (fax)



More information about the Novalug mailing list