Afficher un message
Vieux 24/08/2006, 20h55   #4
Xicheng Jia
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Trying to copy all *.csv files to another directory but fails -

Stephan 'smg' Grein wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> phillip.s.powell@gmail.com wrote:
> > # NOW WE COPY EVERYTHING OVER TO THE NEW FOLDERS IN $csvBackupPath
> > cp -pr "$clientDocPath/*.csv" "$csvBackupPath/clientCSV"
> > cp -pr "$projectDocPath/*.csv" "$csvBackupPath/projectCSV"
> >

> Try that:
> cd "$clientDocPath/" && for file in *.csv; do cp -p "$file"
> "$csvBackupPath/clientCSV/${file}"; done
> cd "$projectDocPath/" && for file in *.csv; do cp -p "$file"
> "$csvBackupPath/projectCSV/${file}"; done


you may get into trouble if "$projectDocPath" is not an absolute path.
to keep the current directory info, you may want to use sub-shell with
your commands, like

( cd "$clientDocPath/" && for file in *.csv; do cp -p "$file"
"$csvBackupPath/clientCSV/${file}"; done )

Also, using 'find' might save OP some typing:

find "$clientDocPath" -type f -name "*.csv"
-exec cp -p "{}" "$csvBackupPath/clientCSV/" \;

or use find | xargs, find -exec ... + .....

(untested)
Xicheng

  Réponse avec citation
 
Page generated in 2,30334 seconds with 9 queries