Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

nat() in pure shell



hello,


On Wed, Oct 03, 2018 at 05:47:19PM +0000, Daniel Shahaf wrote:
> Marc Chantreux wrote on Wed, 03 Oct 2018 18:25 +0200:
> >     nat () {
> >         local -i x=${1-0}
> >         while print $[x++]
> >     }
> 
> Compare:
> yes '' | nl -ba

wow ... good to know nl exists (i missed -nrz all the time). however

     yes '' | nl -ba

is a lot of extra caracters

nat () {
    local -i x=${1-0}
    while print $[x++]
}
nat | sed 2q | xxd

00000000: 300a 310a                                0.1.

awk 'BEGIN{ while (1) print i++ }' | sed 2q | xxd

00000000: 300a 310a                                0.1.

yes '' | nl -ba | sed 2q | xxd

00000000: 2020 2020 2031 090a 2020 2020 2032 090a       1..     2..

regards
marc




Messages sorted by: Reverse Date, Date, Thread, Author