TPIPE /REPLACE - Remove line (including EOL)

x13

Nov 9, 2016
49
0
Netherlands
Hi all.

I haven't been able to figure this out.

I have a text file containing variable length phrases (no line wrap).
I want to remove a specific line including its EOL from the file, but it doesn't work.

I tried :

TPIPE /INPUT=in.txt /OUTPUT=out.txt /REPLACE=0,0,0,0,0,0,0,1,0,"keysize 256","" (works but leaves a blank line)

TPIPE /INPUT=in.txt /OUTPUT=out.txt /REPLACE=0,0,0,0,0,0,0,1,0,"keysize 256\n","" nope
TPIPE /INPUT=in.txt /OUTPUT=out.txt /REPLACE=0,0,0,0,0,0,0,1,0,"keysize 256^m","" nope
TPIPE /INPUT=in.txt /OUTPUT=out.txt /REPLACE=0,0,0,0,0,0,0,1,0,"keysize 256^m^j","" nope
TPIPE /INPUT=in.txt /OUTPUT=out.txt /REPLACE=0,0,0,0,0,0,0,1,0,"keysize 256**","" nope (with actual CR+LF)
TPIPE /INPUT=in.txt /OUTPUT=out.txt /REPLACE=0,0,0,0,0,0,0,1,0,"keysize 256↑*↑*","" nope (with actual CR+LF, preceded by <EscChar>)

TPIPE /INPUT=in.txt /OUTPUT=out.txt /REPLACE=4,0,0,0,0,0,0,1,0,"s/keysize 256\n/","" PERL, still no
TPIPE /INPUT=in.txt /OUTPUT=out.txt /REPLACE=4,0,0,0,0,0,0,1,0,"~/keysize 256\n/","" PERL, still no
Help mentions you can configure the EOL character and whether it is displayed (I assume in TCMD.ini).
But how can I make TPIPE understand that I want the EOL character to also be removed?

A typical substitute command would look like: s/keysize 256^p// (^p, ^m or whatever is valid for context)

I'm sure it's stupid but I don't see it.

It's a shame that help file doesn't contain more in-depth info on TPIPE... (external site?)

Thanks.

x13
 
May 20, 2008
9,274
62
Syracuse, NY, USA
You can do it with /replace (see below) but /replace probably knows nothing about lines and you'll have to specify the CRLF. /grep works with lines and is the better choice. Either way, use a regex to specify the whole line.
Code:
v:\> type threelines.txt
My dog has fleas.
My cat has worms.
My bird has ticks.

v:\> tpipe /input=threelines.txt /replace=4,0,0,0,0,0,0,0,0,"^.*cat has.*\r\n",""
My dog has fleas.
My bird has ticks.

v:\> tpipe /input=threelines.txt /grep=4,0,0,0,0,0,0,0,"^.*cat has.*$"
My dog has fleas.
My bird has ticks.
 
May 20, 2008
9,274
62
Syracuse, NY, USA
(doh!) Since grep works with whole lines, you can simplify that last one. Just make sure you give enough text to pick only the line you want to remove.

Code:
v:\> type threelines.txt
My dog has fleas.
My cat has worms.
My bird has ticks.

v:\> tpipe /input=threelines.txt /grep=4,0,0,0,0,0,0,0,"cat has"
My dog has fleas.
My bird has ticks.