The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 10-07-2007
voa2mp3 voa2mp3 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 3
Post awk field not recognized in backquotes

Hi,

I am writing a script to use awk to generate a set of cp commands from an input file abc.

file abc:
/data/a.dbf
/data/june/b.dbf

desired output:
cp -pr a.dbf /data/a.dbf
cp -pr b.dbf /data/june/b.dbf

script:
$ cat abc | awk '{ print "cp -pr '`basename $1`' " $1 }'

I tried to use awk with basename command, but it seems that the field $1 in backquotes is not recognized by awk. How to fix it?

Many thanks,
voa2mp3