From: Ben Bacarisse on
Barry Margolin <barmar(a)alum.mit.edu> writes:

> In article
> <0.d6c03d7a7e1bf189c62e.20100707141619BST.87lj9nsa8s.fsf(a)bsb.me.uk>,
> Ben Bacarisse <ben.usenet(a)bsb.me.uk> wrote:
>
>> franzi <hazzino(a)gmail.com> writes:
>>
>> > Hi there, it's been a while that i'm not join'g the group
>> > i need some tips..under Leopard is there a way to rm the file not
>> > converted
>>
>> I was puzzled by your use of "not converted"...
>>
>> > textutil -convert html gnu.webarchive i will have gnu.html
>> > i would like to remove the gnu.webarchive can i do like this
>> > textutil -convert html gnu.webarchive| rm {} ?????
>>
>> but working back from this I think you want to remove the source file
>> when the conversion fails (presumably because un-convertable file are of
>> no use to you). You can do that with:
>>
>> textutil -convert html gnu.webarchive || rm gnu.webarchive
>
> Shouldn't || be && ? You want to remove the source if the conversion
> was successful.

That was my first thought but then I read what was written and took
the | as a hint. The OP confirmed my guess though it is possible, I
suppose, that that was done mistakenly.

There is some sense in wanting to remove un-convertible files while
leaving those that do convert. Maybe the conversion is being done to
test the file's validity rather for its actual output.

Anyway, I think it helps that you've brought up the other option just in
case.

> With ||, the second command won't be executed if the first one was
> successful.

--
Ben.
From: blmblm on
In article <0.97b05170f8ae911e8d87.20100707183910BST.87y6dnqji9.fsf(a)bsb.me.uk>,
Ben Bacarisse <ben.usenet(a)bsb.me.uk> wrote:
> franzi <hazzino(a)gmail.com> writes:
>
> >> >> the directory may also matter ("ls -ld .").
> >> >> [2] What does "echo $?" say immediately after "textutil -convert html
> >> >> gnu.webarchive"?
> > sh-3.2$ ls -ld
> > drwx------ 70 hazz staff 2380 Jul 7 17:31 .
> > sh-3.2$ echo $? textutil -convert html /Volumes/Untitled\ 2/Recu_Leo/
> > Leopard/Users/hazzhazz/Documents/UNIX\ tips\:\ Productivity\
> > tips.webarchive "$1"|| rm "$1"
>
> That's not quote what I meant, but it tells me lots anyway. The $1 only
> works if you put the commands in a script or function.

Something it tells me is that the OP's skills are rusty indeed,
either that or he didn't understand your question (2) above --
notice that what he actually typed was not the relevant command
followed by "echo $?" but a single "echo" command.

(I'd second the advice to define a shell function, but that may
be too advanced .... )

> On the command line, your shell may give you a way to refer to a
> previously typed file name, but I don't know what shell you are using.
> Anyway, I think it is simpler to put the commands into a function. You
> can load it every time you start a shell by putting it in one of the
> init files for your shell (again I can't say exactly where).
>
> > 0 textutil -convert html /Volumes/Untitled 2/Recu_Leo/Leopard/Users/
> > hazzhazz/Documents/UNIX tips: Productivity tips.webarchive
> > sh-3.2$ ls -la UNIX\ tips\:\ Productivity\ tips.webarchive
> > -rw-r--r--@ 1 hazz staff 176421 Dec 15 2007 UNIX tips: Productivity
> > tips.webarchive
> > sh-3.2$ whoami
> > hazz
>
> I don't know OSX (if the file names are anything to go by I am glad I
> don't!) but just be sure that the two names you are using for the file
> do indeed refer to the same file.

--
B. L. Massingill
ObDisclaimer: I don't speak for my employers; they return the favor.