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

Re: OT: Bash Scripting Question



On Saturday 09 April 2005 02:23 am, Alex Malinovich wrote:
> On Sat, 2005-04-09 at 01:37 -0400, Hal Vaughan wrote:
> > On Saturday 09 April 2005 01:33 am, Darryl Clarke wrote:
> > > On Apr 9, 2005 1:17 AM, Hal Vaughan <hal@thresholddigital.com> wrote:
> > > > I could swear I remember doing this in the past, but I can't remember
> > > > how, and I hope it wasn't through a recursive script.
> > > >
> > > > I've gone through the man and info pages on ls, but I can't find
> > > > anything (unless I missed the obvious, which has been known to happen
> > > > before) to use to show a way to print out the full path name for EACH
> > > > file or directory in a recursive listing?
> > > >
> > > > Thanks!
> > >
> > > FILES=`ls`
> > > PWD=`pwd`
> > >
> > > for FILE in $FILES;
> > > do
> > >    echo $PWD/$FILE;
> > > done
> >
> > Thanks, but that does for THIS directory, but I'm trying to get the full
> > path for every file in a recursive listing, so if there's a file 3
> > directories deep, I'll get the full pathname for it, instead of just the
> > file name.
>
> find . -printf "`pwd`/%P\n"
>
> (If you don't need the FULL pathname, but only from the current
> directory on up, then just take out the `pwd`/ part.)

This and Steve Lamb's suggestions both worked.  I substituted $() for `` 
because I was using this command as part of a one liner that I had to modify 
just a little a number of times.  Because I had to change it and re-run it a 
number of times, I wanted to stay with a one line bash script (otherwise I'd 
have used Perl).

I was also pretty sure I had seen it done, and that's a feature I've been 
trying to remember for a few weeks.

Thanks for the help!

Hal



Reply to: