in reply to Strange problem trying to clean garbage from start of mailbox file

Why the pipe through more in your system call to sed?
I'd also prefer to close MAILBOX before calling system commands on the file, but that may be irrelevant.
  • Comment on Re: Strange problem trying to clean garbage from start of mailbox file

Replies are listed 'Best First'.
Re^2: Strange problem trying to clean garbage from start of mailbox file
by capoeiraolly (Initiate) on Feb 02, 2006 at 22:54 UTC
    If you don't pipe the sed through more it simple wipes the file. Good idea to close the file handle first. Dosn't do anything for the problem though.
      i'm not a sed expert by any stretch of the imagination, but wouldn't
      sed -i -e '1d' $file
      be a more idiomatic way to write it?

      I believe that piping output into the file you're stream-editing is not the most reliable thing to do. In fact, I'm pretty sure that's why your buffering by "|more" prevents the file from being clobbered.

        I'm no sed expert either, in fact this is the first time I've used it.

        That's a much nicer way of doing things, cheers :)
        Damn, sed on BSD dosn't have the -i option. I'll have a look at the man page to see if there is another way to do an in-place edit.