One problem with -w2 is if the file is >= 100 lines it breaks:

$ nl -w2 -s'. ' ...

98. 
99. 
00. 
01. 
02. 

$ nl -nrz -w2 -s'. ' ...

98. 
99. 
00. 
01. 
02. 

> On Mar 30, 2019, at 3:04 AM, Christopher Stone <[email protected]> 
> wrote:
> 
> On 03/30/2019, at 02:35, Bill Kochman <[email protected] 
> <mailto:[email protected]>> wrote:
>> Chris, you wrote:
>> 
>> #!/usr/bin/env bash
>> nl -nrz -w2 -s'. '
>> 
>> That works on all lines. What about if you have blank lines in the document? 
>> While it works fine on files that have continuous lines of text, the above 
>> indents two spaces and places a period on blank lines.
> 
> 
> Hey Bill,
> 
> The -w2 switch (i.e. -w switch with 2 as its value), designates the width of 
> the padded line number.
> 
> I think the addition of the period in blank lines is a bug in macOS' version 
> of `nl`, because GNU `nl` doesn't have that problem.  (The indention will 
> vary according to -w.)
> 
> 
> #!/usr/bin/env bash
> nl -nrz -ba -w3 -s'. '
> 
> This will number ALL lines including blank ones.
> 
> 
> man nl in the Terminal will get you to the man page for `nl`, so you can see 
> what the various switches do.
> 
> 
> To work around your complaint you can install GNU `nl` with MacPorts or 
> HomeBrew.
> 
> Or you can use a little `sed` to remove the floating period:
> 
> #!/usr/bin/env bash
> nl -nrz -w2 -s'. ' | sed -E 's!^[[:blank:]]+\.!!'
> 
> 
> --
> Take Care,
> Chris
> 
> 
> -- 
> This is the BBEdit Talk public discussion group. If you have a 
> feature request or need technical support, please email
> "[email protected]" rather than posting to the group.
> Follow @bbedit on Twitter: <https://www.twitter.com/bbedit 
> <https://www.twitter.com/bbedit>>
> --- 
> You received this message because you are subscribed to the Google Groups 
> "BBEdit Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> <mailto:[email protected]>.
> To post to this group, send email to [email protected] 
> <mailto:[email protected]>.
> Visit this group at https://groups.google.com/group/bbedit 
> <https://groups.google.com/group/bbedit>.

-- 
Rod Buchanan
Kelly Supply Company
1004 W Oklahoma Ave
Grand Island, NE 68802-1328
308 382-5670
308 382-8764 x1120

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or need technical support, please email
"[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <https://www.twitter.com/bbedit>
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/bbedit.

Reply via email to