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>
--- 
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