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 -->
  #5 (permalink)  
Old 10-07-2007
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,926
Some other ways


Code:
% set -- $(<file)                                                   
% paste -d" " <(printf "cp -pr %s\n" "${@##*/}") <(printf "%s\n" "$@")
cp -pr a.dbf /data/a.dbf
cp -pr b.dbf /data/june/b.dbf

and with zsh:


Code:
zsh 4.3.4% <file while IFS= read;do print -r "cp -pr $REPLY:t $REPLY";done 
cp -pr a.dbf /data/a.dbf
cp -pr b.dbf /data/june/b.dbf

or awk:


Code:
zsh 4.3.4% awk '$0="cp -pr "$NF" "$0' FS="/" file
cp -pr a.dbf /data/a.dbf
cp -pr b.dbf /data/june/b.dbf