I'm interested why they use "seq"? [seq can take a single value too apparently, perhaps they did half width rulers with "seq 2 $(tputs cols)"?]
Why doesn't
!/bin/bash
j=$(tput cols); for i in {1..$j}; do echo -n "#";done
work, presumably there's some escape that needs doing?
The alternative:
!/bin/bash
for (( c=1 ; c<=$COLUMNS; c++ )); do echo -n "#";done
seems fine?
Also BASH has $COLUMNS builtin FWIW, though portability explains use of tput.
I like it, should be a standard command, including options to specify width as a proportion and to add whitespace lines. Code for this must be in almost every shell script.
Both of those would work in bash, but they're non-standard extensions. The seq construction would work in any POSIX shell, though the seq command itself is still non-standard I think.
Comments
I'm interested why they use "seq"? [seq can take a single value too apparently, perhaps they did half width rulers with "seq 2 $(tputs cols)"?]
Why doesn't
work, presumably there's some escape that needs doing?The alternative:
seems fine?Also BASH has $COLUMNS builtin FWIW, though portability explains use of tput.
I like it, should be a standard command, including options to specify width as a proportion and to add whitespace lines. Code for this must be in almost every shell script.
Both of those would work in bash, but they're non-standard extensions. The seq construction would work in any POSIX shell, though the seq command itself is still non-standard I think.
Sorry, the first doesn't work - I was asking if anyone knew why. The second works in BASH, but it's bashism as you note.