Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

in bash how do I separate the escape sequence with the actual number?

Tags:

bash

for example echo -e "\001\033[5m\033[7m\002${var}\001\033[0m\002" If the var is starting with non number character it works. However, if the var starting with number it fails for example var = 5 then the string is "\001\033[5m\033[7m\0025\001\033[0m\002"` for some reason it won't blink the 5 the screen has a blank line

like image 261
Wang Avatar asked Aug 31 '25 23:08

Wang


1 Answers

While there's probably some way to escape a leading digit in ${var} I'd opt to replace echo -e with printf, eg:

printf "\001\033[5m\033[7m\002%s\001\033[0m\002\n" "${var}"

NOTE: added \n on the end to insure we get the same effect as echo

enter image description here

like image 176
markp-fuso Avatar answered Sep 03 '25 11:09

markp-fuso