Hi.
Quote:
Originally Posted by voa2mp3
...
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
...
|
Placing the input on fille "data1", and changing your script slightly to:
Code:
#!/usr/bin/env sh
# @(#) a1 Demonstrate awk feature "command | getline".
set -o nounset
echo
## Use local command version for the commands in this demonstration.
echo "(Versions of codes used in this script -- local code \"version\")"
version bash awk
echo
awk '
{ command = "basename " $1
command | getline file
print "cp -pr " file " " $1 }
' data1
exit 0
produces:
Code:
% ./a1
(Versions of codes used in this script -- local code "version")
GNU bash, version 2.05b.0(1)-release (i386-pc-linux-gnu)
GNU Awk 3.1.4
cp -pr a.dbf /data/a.dbf
cp -pr b.dbf /data/june/b.dbf
cheers, drl