Re: rm in a regular expression



franzi <hazzino@xxxxxxxxx> 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

(You may not need "rm -f" but let's keep things simple for now.) The ||
executes the rm command only if the first command fails.

Your use of {} suggests that you'd like to do this without repeating the
file name. For that I'd write a shell function:

function convert_and_remove
{
textutil -convert html "$1" || rm "$1"
}

which you can use in a script or directly from the command line, but
please don't use this without checking that I've understood your intent!

--
Ben.
.



Relevant Pages

  • Re: rm in a regular expression
    ... when the conversion fails (presumably because un-convertable file are of ... executes the rm command only if the first command fails. ...  For that I'd write a shell function: ...   function convert_and_remove ...
    (comp.unix.shell)
  • Re: Great SWT Program
    ... even if you made the shell ... treat the file as input (manually invoking the command interpreter ... fiddly little switches to type to do a particular conversion, ... Unless the default destination type happens to be pdf, ...
    (comp.lang.java.programmer)
  • Re: Great SWT Program
    ... Twisted did not say foobar and you're a liar. ... information it may have about the destination type is the file name ... conversion from GIF to PDF as opposed to a conversion from TIFF to ... position to set up the relevant command. ...
    (comp.lang.java.programmer)
  • Re: converting to NTFS
    ... > I can't remember all your posts, have you opened a command ... > NTFS. ... > |> But government sees it as an obstacle to be overcome. ...
    (microsoft.public.windowsxp.setup_deployment)
  • Re: converting to NTFS
    ... > This is the answer the command line gives: ... >> But government sees it as an obstacle to be overcome. ... >> NTFS. ...
    (microsoft.public.windowsxp.setup_deployment)