print "*" entire line

Hi folks,

I want to display the "" character the entire line. Instead of manually giving "" multiple times in echo/print command, i want some short cut.

i remember i have came across a straight forward method to display particular character (for example "*" ) for n number of times in unix. but now i forgot the exact source of information.

please help me.

$ x=4
$ printf "%${x}s\n" " " | tr ' ' '*'
****
$ x=10
$ printf "%${x}s\n" " " | tr ' ' '*'
**********

Check out this discussion

A basic shell loop to generate exactly ${MAX} asterisks in a shell variable called ${STRING}.

#!/bin/ksh
COUNTER=0
MAX=10
STRING=""
while true
do
        COUNTER=`expr ${COUNTER} + 1`
        STRING="${STRING}*"
        if [ ${COUNTER} -ge ${MAX} ]
        then
                break
        fi
done
echo "${STRING}"

**********

Ps. I like anbu23's ingenious use of "tr".

perl -le 'print "*" x 80';
********************************************************************************

Very simple in perl .. Change the number accordingly.

if you have python

python -c 'print 80*"*"'

Bash:

printf -v aster "%${COLUMNS}s" " "
printf "%s\n" "${aster// /*}"