Need help with shellscripting logic... - Unix

This is a discussion on Need help with shellscripting logic... - Unix ; 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 was thinking 1 way is to build an if ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: Need help with shellscripting logic...

  1. Need help with shellscripting logic...

    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/


  2. Re: Need help with shellscripting logic...

    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 |
    Shell Scripting Recipes: | My code in this post, if any,
    A Problem-Solution Approach | is released under the
    2005, Apress | GNU General Public Licence

  3. Re: Need help with shellscripting logic...

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


  4. Re: Need help with shellscripting logic...

    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:


    --
    Chris F.A. Johnson, author |
    Shell Scripting Recipes: | My code in this post, if any,
    A Problem-Solution Approach | is released under the
    2005, Apress | GNU General Public Licence

  5. Re: Need help with shellscripting logic...

    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

+ Reply to Thread