[Gllug] Locating Subdirectories

Malcolm Carlock malcolm at carlock.com
Wed Jul 28 22:51:15 UTC 2004


 > Nope, but for fun way more complicated:

Did someone say "complicated"?  Right then.  Here is some complication 
that results in two quick and dirty commands that do what I think you're 
looking for.

Syntax:

    fff expr [more find args]    find files matching expr;
                    can append -exec, -ls, -type d etc if desired;
                    shows full pathname
    ffl expr [more find args]    same as ffl but with relative paths

These commands list out matching files, dirs etc, one per line, and 
permit globbing matches on the commandline without the need to use quotes.

I've been using these for a while.  I don't claim them to be the most 
optimal solutions but they work for me and I use them frequently.

In tcsh:

    alias   fff 'set noglob ; find $cwd \!* ; unset noglob'
    alias   ffl 'set noglob ; find . \!* ; unset noglob'

In ksh/bash:

    alias   fff='set -f ; . $HOME/lib/fff.sh $*'
    alias   ffl='set -f ; . $HOME/lib/ffl.sh $*'

::::::::::
$HOME/lib/fff.sh
::::::::::
# insert various error/arg checks here if you like
find $PWD $*
set +f
::::::::::
$HOME/lib/ffl.sh
::::::::::
# insert various error/arg checks here if you like
find . $*
set +f

Hope this helps.

Malcolm


NB

The behaviour of ffl above is parallelled on the (sorry) CMD/DOS side of 
my world as follows:

    doskey fff=dir/s/b $*

As I am obliged to use W*ndows for part of my work (thankfully a small 
one), I tend to use the CMD/DOS prompt frequently, and have tended to 
have DOS aliases on the Unix side and vice versa.

It's amazing what you can do with a CMD/DOS prompt these days... 
file/dir name completion, fairly complex control statements, even a 
`backquotes` like mechanism.  Syntactically, it's all a horrid mismatch 
of course, and still only a faint shadow of what KSH/BASH/Cygwin can 
do.  However, it can now reasonably be used for actual work.

I see a crowd outside carrying torches, pitchforks and dead cats... 
gotta go.

-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list