in reply to How can I find and delete a line from a file?

Here's a command-line one-liner:

perl -p -i.bak -e "next if /^sandwich,hamburger,/" comma.file

You could wrap this in a batch script or shell alias to facilitate the substitution of parameter values.

Alternatively:

perl -n -i.bak -e "print unless /^sandwich,hamburger,/" comma.file

Replies are listed 'Best First'.
Re: Answer: How can I find and delete a line from a file?
by slvrstn (Initiate) on Oct 28, 2008 at 02:00 UTC
    This actually won't delete the line, since the implied print gets done as part of the continue portion of the loop, which happens even after a next.

    To delete, I think you'd need to substitute the matched line with null, but given that, I think the more obvious way is to switch to explicitly printing, like:

    perl -i -n -e 'print if not /^sandwich,hamburger,/i' comma.file
    This one-liner also takes advantage of the -i switch to edit the file in place, which seemed to be desired in the original question.