Bash create custom string
You can use brace expansion and printf
:
printf "%s\t" ROW1 n{1..300}
The first string specifies the format of output to printf
, and %s
is replaced with a corresponding argument. Since there is only %s
, printf
will re-use the format specifier until all arguments are exhausted. This will leave a trailing tab.
{1..300}
is bash syntax which expands into numbers from 1 to 300, separated by spaces. If a string is added before or after the braces, the expanded form will also have that string attached.
To avoid a trailing tab, you'll have to print something separately, either the first word, or the last:
printf "ROW1"; printf "\tn%d" {1..300}
printf "%s\t" ROW1 n{1..299}; echo n300
Simpler command:
echo -n "ROW1" && echo -ne "\t"n{1..300}
Even simpler thanks to @hildred
echo -ne "ROW1" "\t"n{1..300}