How to make line numbers fixed width in FFIND

May 29, 2008
533
3
Groton, CT
#1
When using FFIND /L , line numbers are rendered as a [n] where n has no leading zeroes. Is there any way to cause the line numbers to be formatted with leading zeroes, like [01] or [001]?
 
May 29, 2008
533
3
Groton, CT
#4
Thanks for the perl of wisdom. I'll try that.
...

I did try it. I downloaded and installed Strawberry Perl, and it worked after I modified the string of four consecutive percent signs down to only two of them.
 
Last edited:

samintz

Scott Mintz
May 20, 2008
1,288
11
Solon, OH, USA
#7
This method doesn't depend on Perl.
Code:
do l in /p ffind /l /v /t"Take" readme.txt (echo.%@rereplace["\[(\d+)\](.+)",[%@format[03,\1]]\2,%l])
However, there appears to be a bug in @format. I imagine there's a way to do it using the built-in Lua interpreter too, or tpipe.
 

samintz

Scott Mintz
May 20, 2008
1,288
11
Solon, OH, USA
#10
It's kind of like programming in APL. You have no idea what the code does and it's usually easier just to rewrite it than trying to figure it out. It took me 20 minutes of futzing with the switches and various options before I figured it out.
 
#11
Here's one that uses the ridiculously complicated TPIPE
Code:
tpipe /input=readme.txt /line=1,1,0,0,-7.5d /grep=3,0,0,0,0,0,0,0,Take
Nice one, Scott. It only took an hour to figure this out, but you can get the []s in there too.
Code:
g:\tc18> tpipe /input=readme.txt /line=1,1,0,0,-7.5d /grep=3,0,0,0,0,0,0,0,Take /replace=4,0,0,0,0,0,0,0,0,"^^(\d+?)",[$1]
[00001]  Take Command v18.0
[00012]  Greetings, and thanks for trying Take Command!
<snip>