in reply to Re^2: Strange problem trying to clean garbage from start of mailbox file
in thread Strange problem trying to clean garbage from start of mailbox file

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.

  • Comment on Re^3: Strange problem trying to clean garbage from start of mailbox file
  • Download Code

Replies are listed 'Best First'.
Re^4: Strange problem trying to clean garbage from start of mailbox file
by capoeiraolly (Initiate) on Feb 02, 2006 at 23:42 UTC
    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 :)
Re^4: Strange problem trying to clean garbage from start of mailbox file
by capoeiraolly (Initiate) on Feb 02, 2006 at 23:45 UTC
    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.
      Um, what sort of BSD are you using? When I do "man sed" on freebsd (and the bsd-based darwin on my mac), I see:
      -i extension Edit files in-place, saving backups with the specified extension +. If a zero-length extension is given, no backup will be saved. I +t is not recommended to give a zero-length extension when in-place editing files, as you risk corruption or partial content in situ +- ations where disk space is exhausted, etc.
        Not sure which flavour of BSD is installed on this box as I didn't set it up myself, however sed -i produces :
        sed: illegal option -- i usage: sed script [-an] [file ...] sed [-an] [-e script] ... [-f script_file] ... [file ...]