in reply to delete last CR and LF from txt

If you know the crlf will always be there:

perl -E"$s=-s $ARGV[ 0 ]; truncate( $ARGV[0], $s-2 ) or die $!" junk.d +at

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"I'd rather go naked than blow up my ass"

Replies are listed 'Best First'.
Re^2: delete last CR and LF from txt
by bot403 (Beadle) on Feb 22, 2010 at 23:00 UTC
    Even if you dont know its there you can seek to the last 2 bytes and read them and compare them to CR/LF. If they are indeed a CR/LF then truncate, else leave it alone. Its not quite a one-liner but still tiny.