Unix questions - Need help with shellscripting logic...

This is Interesting: Free IT Magazines  
Home > Archive > Unix questions > November 2005 > Need help with shellscripting logic...





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Need help with shellscripting logic...
Jigar2Reshma@gmail.com

2005-11-29, 5:58 pm

I need some help with this logic=E2=80=A6.
I have the following script..

My source is always
/u01_p/test and
/u02_p/test

This is my logic
for i in `cat dbmap|awk '{for (i=3D2; i<=3DNF; ++i) print $i}'`; =EF=83=
=9F I
was thinking 1 way is to build an if statement around the for loop and
grep for only test
do
echo cp -p -r ${i} $i/oradata/$sid
done

which does the following

cp -p -r /u09p /u09
cp -p -r /u10p /u10
cp -p -r /u01p /u01
cp -p -r /u02p /u02

but that is not what I want=E2=80=A6
cat dbmap (tab deliminated) mapping file for oracle instances
test /u09 /u10
dev /u01 /u02

how can I only grep for test mountpoints and build my cp command? Such
as

cp =E2=80=93rp /u09_p/jbld /u09/oradata/test/
cp =E2=80=93rp /u10_p/jbld /u10/oradata/test/

Chris F.A. Johnson

2005-11-29, 5:58 pm

On 2005-11-29, Jigar2Reshma@gmail.com wrote:
> I need some help with this logic?.
> I have the following script..
>
> My source is always
> /u01_p/test and
> /u02_p/test
>
> This is my logic
> for i in `cat dbmap|awk '{for (i=2; i<=NF; ++i) print $i}'`; ? I
> was thinking 1 way is to build an if statement around the for loop and
> grep for only test
> do
> echo cp -p -r ${i} $i/oradata/$sid
> done
>
> which does the following
>
> cp -p -r /u09p /u09
> cp -p -r /u10p /u10
> cp -p -r /u01p /u01
> cp -p -r /u02p /u02
>
> but that is not what I want?
> cat dbmap (tab deliminated) mapping file for oracle instances
> test /u09 /u10
> dev /u01 /u02
>
> how can I only grep for test mountpoints and build my cp command? Such
> as
>
> cp ?rp /u09_p/jbld /u09/oradata/test/
> cp ?rp /u10_p/jbld /u10/oradata/test/


grep ^test dbmap |
while read x src dest
do
printf "cp -rp %s/jbld %s/oradata/test\n" "${src%p}_p" "$dest"
done

--
Chris F.A. Johnson, author | <http://cfaj.freeshell.org>
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence
Jigar2Reshma@gmail.com

2005-11-29, 5:58 pm

Thanks..how do i incorporate your logic withing my loop? I am new @
shellscripting.

Chris F.A. Johnson

2005-11-29, 5:58 pm

On 2005-11-29, Jigar2Reshma@gmail.com wrote:
> Thanks..how do i incorporate your logic withing my loop? I am new @
> shellscripting.


What logic? What loop?

Please read: <http://cfaj.freeshell.org/google>


--
Chris F.A. Johnson, author | <http://cfaj.freeshell.org>
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence
Bit Twister

2005-11-29, 5:58 pm

On 29 Nov 2005 13:10:39 -0800, Jigar2Reshma@gmail.com wrote:
> Thanks..how do i incorporate your logic withing my loop? I am new @
> shellscripting.


These might help.

! bash script introduction documentation
http://tldp.org/LDP/intro-linux/html/index.html
! bash script advanced documentation
http://tldp.org/LDP/abs/html/index.html
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com