cd to multiple directories

Timothy Washington timothyjwashington at yahoo.ca
Tue May 21 05:49:05 PDT 2002


Muchos Gracias. This works beautifully.

t

--- Richard Lightman <richard at nezumi.plus.com> wrote:
> * Timothy Washington <timothyjwashington at yahoo.ca>
> [2002-05-21 07:50]:
> > I want to be able to change into multiple
> directories
> > and perform commands.
> > 
> > Any hints?
> > 
> find / -type d -maxdepth 1 -exec bash -c 'cd {}; ls'
> \;
> 
> {} gets replaced by the directoies that find finds.
> Find needs a ; to spot the end of the arguments for
> the bash command.
> That ; needs a backslash so the shell will not
> interpret it.
> Replace ls with whatever you want.
> 
> 
> You may well be better of with something like:
> 
> find / -type d -maxdepth 1 -print0 | xargs -0 ls
> 
> This does not change directory, but you probably do
> not need to, your
> command gets a list of pathnames. The documentation
> for xargs lives in
> the info page for find (type 'info find').
> 
> 
> 99% of bash scripting is using the most appropriate
> command that is
> not a part of bash. I know you have already met
> grep. Here is a list
> of things in a vaguley sensible order:
> 
> grep, cut,
> very simple sed (If the script is not simple, try
> awk or grep instead)
> sort, uniq, com,
> awk,
> find, xargs,
> head, tail, split, tac.
> 
> By the time a bash script uses all of these, you
> have past the point
> when you would have been better off with perl or
> python.
> 
> Richard
> -- 
> Unsubscribe: send email to
> listar at linuxfromscratch.org
> and put 'unsubscribe blfs-support' in the subject
> header of the message
> 


=====
Timothy Washington
timothyjwashington at yahoo.ca

______________________________________________________________________ 
Find, Connect, Date! http://personals.yahoo.ca
-- 
Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe blfs-support' in the subject header of the message



More information about the blfs-support mailing list