I'm trying to do the following:
ch='\x21'
line="\x21"
len=50
for i in `seq 1 $len`
do
line+="$ch"
done
Instead of 50 '!' (hex code \x21) I get a list of 50 '\x21'. How can I do this in bash?
I'm trying to do the following:
ch='\x21'
line="\x21"
len=50
for i in `seq 1 $len`
do
line+="$ch"
done
Instead of 50 '!' (hex code \x21) I get a list of 50 '\x21'. How can I do this in bash?
Per the man page, "Words of the form $'string' are treated specially". Thus, adding $'' to the mix may help:
% bash
bash-3.2$ ch=$'\x21'; echo $ch$ch$ch
!!!
bash-3.2$