Copy files using AWK's output 
Author Message
 Copy files using AWK's output

Hi ,
 I am using awk to parse a flat file and get arguments for copying function.

 awk one liner given below prints first and second fields of flat file.
 I wanted to know how to use this o/p to copy file from field1 to dir in
field2

 And here is awk one liner to parse this file :

 awk -F" ", '$1 !~ /FileName/ { print $1, $2 }' flat-file-name

 Here is sample contents of flat file :

 FileName ToDist
 thisfile       /desti/nation/path
 thatfile      /desti/nation/path

 Now how can I use xargs (or may be some other way) to copy file in field1
to dir in field2 ?

 I work on a system running Solaris 2.6 under bash.
 And I wil be using these functions in Makefile.

TIA,
Rams



Sat, 29 Oct 2005 18:54:33 GMT  
 Copy files using AWK's output

Quote:
> Hi ,
>  I am using awk to parse a flat file and get arguments for copying function.

>  awk one liner given below prints first and second fields of flat file.
>  I wanted to know how to use this o/p to copy file from field1 to dir in
> field2

>  And here is awk one liner to parse this file :

>  awk -F" ", '$1 !~ /FileName/ { print $1, $2 }' flat-file-name

>  Here is sample contents of flat file :

>  FileName ToDist
>  thisfile       /desti/nation/path
>  thatfile      /desti/nation/path

>  Now how can I use xargs (or may be some other way) to copy file in field1
> to dir in field2 ?

awk 'NR != 1 { print "mv " $1,$2 }' fil | sh

--
Stein Arne



Sat, 29 Oct 2005 20:13:41 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Outputting info from awk and using the info to name the awk output file

2. using awk to format ifconfig -a output

3. copying files using as a different file name

4. copy , using 'system'

5. Can't get AWK output to a PERL script

6. copy a file from within awk?

7. awk output to a new file

8. awk output into file during processing

9. run awk output thru tee inside awk

10. Naming the output file based on awk script variable

11. Copy 'DOS' File to another directory

12. Pretty 'print' files from awk

 

 
Powered by phpBB® Forum Software