begin quoting Todd Walton as of Mon, Jul 11, 2005 at 09:41:31PM -0700: > On 7/11/05, Stewart Stremler <[EMAIL PROTECTED]> wrote: [snip] > > You can't give it stdin and redirect stdout? > > No. It's not very flexible in that regard. Whatever you give it, it says: > > Usage: /usr/bin/wvText <word document> <text output file> Bummer. Do you have source, perchance? :)
> > Why? I don't see any bash-specific stuff going on here. What's wrong
> > with sh?
>
> Frankly, it's because I don't know the differences between bash and
> sh, and I'd rather stick with bash and learn to use bash. The only
> reason I can see for going with sh is portability, and I don't value
> that for this application.
I figure it's just a good habit. Make the fewest necessary assumptions.
Sooner or later you're going to try to write a portable script, and
you're going to specify bash needlessly, and confuse people.
> > In tcsh, you use stuff like :t and :r to to that. So something like:
> >
> > foreach i ( /dir/full/of/files/* )
> > wvText $i ${i:t:r}.text
> > end
> >
> > ...does a fine job.
>
> I'll try that.
I believe that :r and :t are csh-compatible as well.
> > wvText $1 `basename $1 .doc`.text
>
> No go. When I create a shell script with this, and then run it on the
> files, it doesn't work. Both:
>
> $ myScript *
> $ ls |xargs myScript
>
> convert only the first file, and not the rest. This should work!
Oh, naturally. I figured you were trying something like
% find $dir -name '*.doc' -exec myScript {} \;
Or
$ for i in *.doc do; myScript $i; done
If you want to have 'myScript' take many files, you need to loop on the
input.
-----------------------------------------------------------------------------
#!/bin/sh
for i in $@; do
wvText $i `basename $i .doc`.text
done
-----------------------------------------------------------------------------
Or you can use 'shift' and a while-loop, IIRC.
-Stewart "More than one way to do it in more than one shell language" Stremler
pgpchUzKCPyM7.pgp
Description: PGP signature
-- [email protected] http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list
