[rescue] shell script question

Steve Sandau rescue at sunhelp.org
Fri Oct 26 12:09:01 CDT 2001


With #!/bin/sh something like

cd /foo
for dir in `find . | grep RCS`
  do
    mv $dir $dir.old
    ln -s /new/$dir /foo/$dir
  done

might do it.

Depends on how variable the names foo and new are. If they're always the
same, this may work. If they vary, it'll get tougher.

Nick Kociuk wrote:
> 
> this is really only specifically sun-related in that i'm using solaris,
> and this seemed like less of a geeks-list question.
> 
> anyway, i've been futzing around for the past hour or so trying to write
> what i'm certain should be a simple shell script, but i'm getting no
> where quickly.  a simple web search turned up nothing that i didn't
> already know.
> 
> what i'm tring to do is this:
> 
> i've got a bunch of directories (actually, some are symlinks, but that
> should be easy enough to handle)
> 
> /foo/bar1/.../RCS
> /foo/bar2/.../RCS
> 
> and i'd like to rename the RCS leaf directories to RCS.old, this part
> is pretty simple...  but i also want to create new sym-links in their
> place.  ie:
> 
> /foo/bar1/.../RCS -> /new/bar1/.../RCS
> 
> so the name of the link target is the same except for the first
> directory name.  this is where i'm running into problems, since my
> string parsing/tokenizing skills are quite lacking when it comes to shell
> scripts.
> 
> i'd appreciate any pointers/suggestions as to how to go about doing
> this.  thanks.
> 
> _______________________________________________
> rescue maillist  -  rescue at sunhelp.org
> http://www.sunhelp.org/mailman/listinfo/rescue

-- 
Steve Sandau, IS Technician
TMA Bath, Maine
ssandau at bath.tmac.com



More information about the rescue mailing list