[rescue] shell script question

Randy Bowie rescue at sunhelp.org
Fri Oct 26 14:11:32 CDT 2001


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C15E52.05E0C3B0
Content-Type: text/plain;
	charset="iso-8859-1"

Something like:

#!/bin/sh
PATH=/bin:/usr/bin:/usr/ucb
for i in `find /foo`
do
 case $i in
  *RCS) {
       NEW="`dirname $i | sed 's/^\/foo/\/new/'`"
       mv $i $i.old
       ln -s $NEW/RCS $i
       };;
 esac
done


Might work.  I haven't tested it.  You may want to play with find options to
follow symlinks properly.     

-----Original Message-----
From: Nick Kociuk [mailto:nkociuk at ieee.org]
Sent: Friday, October 26, 2001 11:54 AM
To: rescue at sunhelp.org
Subject: [rescue] shell script question


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

------_=_NextPart_001_01C15E52.05E0C3B0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2653.12">
<TITLE>RE: [rescue] shell script question</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=3D2>Something like:</FONT>
</P>

<P><FONT SIZE=3D2>#!/bin/sh</FONT>
<BR><FONT SIZE=3D2>PATH=3D/bin:/usr/bin:/usr/ucb</FONT>
<BR><FONT SIZE=3D2>for i in `find /foo`</FONT>
<BR><FONT SIZE=3D2>do</FONT>
<BR><FONT SIZE=3D2> case $i in</FONT>
<BR><FONT SIZE=3D2>  *RCS) {</FONT>
<BR><FONT SIZE=3D2>       =
NEW=3D"`dirname $i | sed 's/^\/foo/\/new/'`"</FONT>
<BR><FONT SIZE=3D2>       mv $i =
$i.old</FONT>
<BR><FONT SIZE=3D2>       ln -s $NEW/RCS =
$i</FONT>
<BR><FONT SIZE=3D2>       };;</FONT>
<BR><FONT SIZE=3D2> esac</FONT>
<BR><FONT SIZE=3D2>done</FONT>
</P>
<BR>

<P><FONT SIZE=3D2>Might work.  I haven't tested it.  You may =
want to play with find options to follow symlinks =
properly.     </FONT>
</P>

<P><FONT SIZE=3D2>-----Original Message-----</FONT>
<BR><FONT SIZE=3D2>From: Nick Kociuk [<A =
HREF=3D"mailto:nkociuk at ieee.org">mailto:nkociuk at ieee.org</A>]</FONT>
<BR><FONT SIZE=3D2>Sent: Friday, October 26, 2001 11:54 AM</FONT>
<BR><FONT SIZE=3D2>To: rescue at sunhelp.org</FONT>
<BR><FONT SIZE=3D2>Subject: [rescue] shell script question</FONT>
</P>
<BR>

<P><FONT SIZE=3D2>this is really only specifically sun-related in that =
i'm using solaris,</FONT>
<BR><FONT SIZE=3D2>and this seemed like less of a geeks-list =
question.</FONT>
</P>

<P><FONT SIZE=3D2>anyway, i've been futzing around for the past hour or =
so trying to write</FONT>
<BR><FONT SIZE=3D2>what i'm certain should be a simple shell script, =
but i'm getting no</FONT>
<BR><FONT SIZE=3D2>where quickly.  a simple web search turned up =
nothing that i didn't</FONT>
<BR><FONT SIZE=3D2>already know.</FONT>
</P>

<P><FONT SIZE=3D2>what i'm tring to do is this:</FONT>
</P>

<P><FONT SIZE=3D2>i've got a bunch of directories (actually, some are =
symlinks, but that</FONT>
<BR><FONT SIZE=3D2>should be easy enough to handle)</FONT>
</P>

<P><FONT SIZE=3D2>/foo/bar1/.../RCS</FONT>
<BR><FONT SIZE=3D2>/foo/bar2/.../RCS</FONT>
</P>

<P><FONT SIZE=3D2>and i'd like to rename the RCS leaf directories to =
RCS.old, this part</FONT>
<BR><FONT SIZE=3D2>is pretty simple...  but i also want to create =
new sym-links in their</FONT>
<BR><FONT SIZE=3D2>place.  ie:</FONT>
</P>

<P><FONT SIZE=3D2>/foo/bar1/.../RCS -> /new/bar1/.../RCS</FONT>
</P>

<P><FONT SIZE=3D2>so the name of the link target is the same except for =
the first</FONT>
<BR><FONT SIZE=3D2>directory name.  this is where i'm running into =
problems, since my</FONT>
<BR><FONT SIZE=3D2>string parsing/tokenizing skills are quite lacking =
when it comes to shell</FONT>
<BR><FONT SIZE=3D2>scripts.</FONT>
</P>

<P><FONT SIZE=3D2>i'd appreciate any pointers/suggestions as to how to =
go about doing</FONT>
<BR><FONT SIZE=3D2>this.  thanks.</FONT>
</P>

<P><FONT =
SIZE=3D2>_______________________________________________</FONT>
<BR><FONT SIZE=3D2>rescue maillist  -  =
rescue at sunhelp.org</FONT>
<BR><FONT SIZE=3D2><A =
HREF=3D"http://www.sunhelp.org/mailman/listinfo/rescue" =
TARGET=3D"_blank">http://www.sunhelp.org/mailman/listinfo/rescue</A></FO=
NT>
</P>

</BODY>
</HTML>
------_=_NextPart_001_01C15E52.05E0C3B0--



More information about the rescue mailing list