|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 (permalink) |
|
Messages: n/a
Hébergeur: |
# NOW WE COPY EVERYTHING OVER TO THE NEW FOLDERS IN $csvBackupPath
cp -pr "$clientDocPath/*.csv" "$csvBackupPath/clientCSV" cp -pr "$projectDocPath/*.csv" "$csvBackupPath/projectCSV" This code I thought would simply copy everything ending in ".csv" to another directory, but I get the following error: No such file or directory *.csv What must I do to ensure copying files over? Thanx Phil |
|
|
|
#2 (permalink) |
|
Messages: n/a
Hébergeur: |
-----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 > This code I thought would simply copy everything ending in ".csv" to > another directory, but I get the following error: > > No such file or directory *.csv You got wrong with the * quantifier. > > What must I do to ensure copying files over? try above ![]() > > Thanx > Phil > np - -- Stephan 'smg' Grein, <stephan at stephan minus rockt dot de> https://stephangrein.de GnuPG-Key-ID: 0xF8C275D4 FingerPrint: 5B6F 134A 189B A24D 342B 0961 8D4B 0230 F8C2 75D4 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) iQIVAwUBRO3cJo1LAjD4wnXUAQLXAQ//azcZborYgbII4xSx7vHxDrIMTGSPyDdF leKFQ2+ql1geK6L2vKfhbc84JlUU5EPp3EWXtsHc1jRAi65yzs H6ndKoogkSodRT oaFy4v9AuAfzxmoYn0qluC6dgJkaKYySjH5GjPKd7n4anebB1e PVmg3TzDZPen07 9BvtNBd+FVBqf+RUPMp/C2uKoncFMb4Nr3aJG4aWj3SvK5O9kuw5CqUTPBQ6cz7j Z5+LF6vA3vS85zr6hvAINuASyR/B9nTgioAxjUPiBIBuY13HuggDOMZImqayc4B0 iE0qPesW5n0F5WyrbV0MBDo09cugMvMCvzw/J0S7/gK2c97g959HG5pghnyMTE2W jvQ0Ke7k/ojWZdhnNy+KSLRRzS2Ga9ZcDol8OWeldPmyWzkPsgsIRnD6aNH dDwey pZxwlX0etjn4ff95IM6OLltXEgsXYmgkm9PuXEq+cO5aeAb7Jc y9fGz8myCz2mWC ldSn8wfK57sJ8iMQdv2Twtndc06rOVRYUaSw5J1kcheRezqOjJ qy4YM8i4E8S5Qb GvkJlXAAZm8PWHWdJKrW4Qlr80MZLisHevAgLtxbtclczkM7KE CGheGtWxQ+KuPE 6SWRlFh5N4rrZpwm18A53fUnn/D2Rt+zdhAK+ty48T3XeeIHipqkrZ7vSWAdbu/o ya1Uhw9zJiU= =VzzK -----END PGP SIGNATURE----- |
|
|
|
#3 (permalink) |
|
Messages: n/a
Hébergeur: |
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 > > > This code I thought would simply copy everything ending in ".csv" to > > another directory, but I get the following error: > > > > No such file or directory *.csv > You got wrong with the * quantifier. > > > > What must I do to ensure copying files over? > > try above ![]() > > > > Thanx > > Phil > > > np Could you please explain that? None of it made sense to me, what is that/?? Phil > > - -- > Stephan 'smg' Grein, <stephan at stephan minus rockt dot de> > https://stephangrein.de > GnuPG-Key-ID: 0xF8C275D4 > FingerPrint: 5B6F 134A 189B A24D 342B 0961 8D4B 0230 F8C2 75D4 > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.5 (GNU/Linux) > > iQIVAwUBRO3cJo1LAjD4wnXUAQLXAQ//azcZborYgbII4xSx7vHxDrIMTGSPyDdF > leKFQ2+ql1geK6L2vKfhbc84JlUU5EPp3EWXtsHc1jRAi65yzs H6ndKoogkSodRT > oaFy4v9AuAfzxmoYn0qluC6dgJkaKYySjH5GjPKd7n4anebB1e PVmg3TzDZPen07 > 9BvtNBd+FVBqf+RUPMp/C2uKoncFMb4Nr3aJG4aWj3SvK5O9kuw5CqUTPBQ6cz7j > Z5+LF6vA3vS85zr6hvAINuASyR/B9nTgioAxjUPiBIBuY13HuggDOMZImqayc4B0 > iE0qPesW5n0F5WyrbV0MBDo09cugMvMCvzw/J0S7/gK2c97g959HG5pghnyMTE2W > jvQ0Ke7k/ojWZdhnNy+KSLRRzS2Ga9ZcDol8OWeldPmyWzkPsgsIRnD6aNH dDwey > pZxwlX0etjn4ff95IM6OLltXEgsXYmgkm9PuXEq+cO5aeAb7Jc y9fGz8myCz2mWC > ldSn8wfK57sJ8iMQdv2Twtndc06rOVRYUaSw5J1kcheRezqOjJ qy4YM8i4E8S5Qb > GvkJlXAAZm8PWHWdJKrW4Qlr80MZLisHevAgLtxbtclczkM7KE CGheGtWxQ+KuPE > 6SWRlFh5N4rrZpwm18A53fUnn/D2Rt+zdhAK+ty48T3XeeIHipqkrZ7vSWAdbu/o > ya1Uhw9zJiU= > =VzzK > -----END PGP SIGNATURE----- |
|
|
|
#4 (permalink) |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#5 (permalink) |
|
Messages: n/a
Hébergeur: |
On 24 Aug 2006 10:10:52 -0700, phillip.s.powell@gmail.com
<phillip.s.powell@gmail.com> wrote: > > 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 >> >> > This code I thought would simply copy everything ending in ".csv" to >> > another directory, but I get the following error: >> > >> > No such file or directory *.csv >> You got wrong with the * quantifier. >> > >> > What must I do to ensure copying files over? >> >> try above ![]() >> > >> > Thanx >> > Phil >> > >> np > > > Could you please explain that? None of it made sense to me, what is > that/?? > > Phil > In sh and similar shells, if there is no file matching a wildcard expression, the wildcard expression is left as is on the command line. To avoid an error, you can use if [ -f "$clientDocPath/*.csv" ]; then cp -pr "$clientDocPath/*.csv" "$csvBackupPath/clientCSV" fi -- Truth is the most valuable thing we have -- so let us economize it. -- Mark Twain |
|
|
|
#6 (permalink) |
|
Messages: n/a
Hébergeur: |
On 2006-08-24, 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" > > This code I thought would simply copy everything ending in ".csv" to > another directory, but I get the following error: > > No such file or directory *.csv Filenames are not expanded inside quotes: cp -pr "$clientDocPath/"*.csv "$csvBackupPath/clientCSV" cp -pr "$projectDocPath/"*.csv "$csvBackupPath/projectCSV" -- Chris F.A. Johnson, author <http://cfaj.freeshell.org> Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) ===== My code in this post, if any, assumes the POSIX locale ===== and is released under the GNU General Public Licence |
|
|
|
#7 (permalink) |
|
Messages: n/a
Hébergeur: |
On 2006-08-24, Bill Marcum wrote:
> On 24 Aug 2006 10:10:52 -0700, phillip.s.powell@gmail.com > <phillip.s.powell@gmail.com> wrote: >> >> 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 >>> >>> > This code I thought would simply copy everything ending in ".csv" to >>> > another directory, but I get the following error: >>> > >>> > No such file or directory *.csv >>> You got wrong with the * quantifier. >>> > >>> > What must I do to ensure copying files over? >>> >>> try above ![]() >> >> Could you please explain that? None of it made sense to me, what is >> that/?? >> > In sh and similar shells, if there is no file matching a wildcard > expression, the wildcard expression is left as is on the command > line. To avoid an error, you can use > > if [ -f "$clientDocPath/*.csv" ]; then That doesn't work, because the wildcard will not be expanded. > cp -pr "$clientDocPath/*.csv" "$csvBackupPath/clientCSV" > fi > > -- Chris F.A. Johnson, author <http://cfaj.freeshell.org> Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) ===== My code in this post, if any, assumes the POSIX locale ===== and is released under the GNU General Public Licence |
|
![]() |
| Outils de la discussion | |
|
|