[an error occurred while processing this directive]

  • Deleting all characters after a "keyword"? - OWTDI
    By : anonymous ( Tue Feb 10 11:18:48 2004 )

    [user@machine]: cat file.txt
    This is just a test to see if
    the Perl on-liner will delete
    everything following this KEYWORD

    lakjn e3r
    aoer
    aoej
    [poI3
    [PTRI
    [PIGFO AJ'3;ORJ
    A[3OPIR
    I

    And here's the one-liner:
    perl -pi -e "{undef $/; s/(.*KEYWORD).*/$1/s}" file.txt

    RESULT:
    This is just a test to see if
    the Perl on-liner will delete
    everything following this KEYWORD

    Return to article...[an error occurred while processing this directive]