Unix questions - File Parsing question: URGENT

This is Interesting: Free IT Magazines  
Home > Archive > Unix questions > November 2005 > File Parsing question: URGENT





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 File Parsing question: URGENT
Jigar2Reshma@gmail.com

2005-11-29, 5:58 pm

Hello everyone, i need the syntax for the following example..here is my
mapping file.
[code]
> cat newmaptest

this is source this is destination
/s01/oradata/jbld:/u01/oradata/test
/s02/oradata/jbld:/u02/oradata/test
[/code]

how can i get the following command
cp -rp /s01/oradata/jbld /u01/oradata/test
cp -rp /s02/oradata/jbld /u02/oradata/test


thanks a lot

Shekar

2005-11-29, 5:58 pm

cat newmaptest|awk -F: '{printf "cp -rp %s %s\n", $1, $2}'

Ed Morton

2005-11-29, 5:58 pm

Shekar wrote:
> cat newmaptest|awk -F: '{printf "cp -rp %s %s\n", $1, $2}'
>


UUOC:

awk -F: '{printf "cp -rp %s %s\n", $1, $2}' newmaptest

Regards,

Ed.
Ed Morton

2005-11-29, 5:58 pm

Jigar2Reshma@gmail.com wrote:

> Hello everyone, i need the syntax for the following example..here is my
> mapping file.
> [code]
>
>
> this is source this is destination
> /s01/oradata/jbld:/u01/oradata/test
> /s02/oradata/jbld:/u02/oradata/test
> [/code]
>
> how can i get the following command
> cp -rp /s01/oradata/jbld /u01/oradata/test
> cp -rp /s02/oradata/jbld /u02/oradata/test
>
>
> thanks a lot
>


awk -F: 'NR==1{next}{printf "cp -rp %s %s\n", $1, $2}' newmaptest

Regards,

Ed.
Christopher W Aiken

2005-11-30, 5:55 pm

On 2005-11-29, Jigar2Reshma@gmail.com <Jigar2Reshma@gmail.com> wrote:
> Hello everyone, i need the syntax for the following example..here is my
> mapping file.
> [code]
> this is source this is destination
> /s01/oradata/jbld:/u01/oradata/test
> /s02/oradata/jbld:/u02/oradata/test
> [/code]
>
> how can i get the following command
> cp -rp /s01/oradata/jbld /u01/oradata/test
> cp -rp /s02/oradata/jbld /u02/oradata/test
>
>
> thanks a lot
>


In tcsh:

foreach i (`cat newmaptest`)
set src=`echo $i | cut -f1 -d":"`
set dst=`echo $i | cut -f2 -d":"`
cp -rp $src $dst
end

--
-=[cwa]=-
e-Mail: chris at cwaiken dot net
Home: www.cwaiken.net



Chuck Dillon

2005-11-30, 5:55 pm

Jigar2Reshma@gmail.com wrote:
> Hello everyone, i need the syntax for the following example..here is my
> mapping file.
> [code]
>
>
> this is source this is destination
> /s01/oradata/jbld:/u01/oradata/test
> /s02/oradata/jbld:/u02/oradata/test
> [/code]
>
> how can i get the following command
> cp -rp /s01/oradata/jbld /u01/oradata/test
> cp -rp /s02/oradata/jbld /u02/oradata/test
>
>
> thanks a lot
>


sed 's/^/cp -rp /;s/:/ /' newmaptest | sh

--
Chuck Dillon
Senior Software Engineer
NimbleGen Systems Inc.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com