|
Home > Archive > Unix Shell > October 2004 > How can I add filesnames with spaces to my zip archive?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
How can I add filesnames with spaces to my zip archive?
|
|
| D. Alvarado 2004-10-04, 6:01 pm |
| Hello,
I am running Solaris 8 and using ksh. I am trying to add some html
files to an existing zip archive. The problem is, some of the zip
files contain spaces in the file name. So when I try
find "$filename" -name "*.html" | xargs zip -r "$basename.zip"
I get a lot of errors ...
zip warning: name not matched: /export/home/dalvorad/Liv
zip warning: name not matched: files
zip warning: name not matched: to
zip warning: name not matched: convert/sh/hst05/IN/no
zip warning: name not matched: dic/page340-1.html
zip warning: name not matched: /export/home/dalvorad/Liv
zip warning: name not matched: files
zip warning: name not matched: to
zip warning: name not matched: convert/sh/hst05/IN/no
zip warning: name not matched: dic/page340-2.html
zip warning: name not matched: /export/home/dalvorad/Liv
zip warning: name not matched: files
zip warning: name not matched: to
zip warning: name not matched: convert/sh/hst05/IN/no
to list a few. Assuming I can't rename the files I'm looking for, how
could I improve/rewrite the above statement?
Thanks, - Dave
| |
| Stephane CHAZELAS 2004-10-04, 6:01 pm |
| 2004-10-4, 07:29(-07), D. Alvarado:
> Hello,
> I am running Solaris 8 and using ksh. I am trying to add some html
> files to an existing zip archive. The problem is, some of the zip
> files contain spaces in the file name. So when I try
>
> find "$filename" -name "*.html" | xargs zip -r "$basename.zip"
[...]
/usr/xpg4/bin/find "$filename" -name "*.html" \
-exec zip -r "$basename.zip" {} +
--
Stephane
| |
| Stephen Riehm 2004-10-04, 6:01 pm |
| D. Alvarado wrote:
> Hello,
> I am running Solaris 8 and using ksh. I am trying to add some html
> files to an existing zip archive. The problem is, some of the zip
> files contain spaces in the file name. So when I try
>
> find "$filename" -name "*.html" | xargs zip -r "$basename.zip"
I'm not sure if this was implemented in solaris 8 (I've only got access
to solaris 9 - and this feature is available there), but have a look for
find ... -print0 and xargs -0 (zero). These print and parse the file
names null-terminated, so spaces are no longer an issue. (An old GNU
feature which has been in most mainstream uni*s for quite a while now).
To use your example:
find "$filename" -name \*.html -print0 | xargs -0 zip -r "$basename.zip"
($filename should of course be a $directory, but you knew that right? ;-)
Good luck,
Steve
|
|
|
|
|