Warning: include() [function.include]: URL file-access is disabled in the server configuration in /home/.showoff/linuxfaqs/linux-faqs.com/HOWTO/Bash-Prompt-HOWTO/c583.php on line 34

Warning: include(http://www.linux-faqs.com/HOWTO/header.inc) [function.include]: failed to open stream: no suitable wrapper could be found in /home/.showoff/linuxfaqs/linux-faqs.com/HOWTO/Bash-Prompt-HOWTO/c583.php on line 34

Warning: include() [function.include]: Failed opening 'http://www.linux-faqs.com/HOWTO/header.inc' for inclusion (include_path='.:/usr/local/php5/lib/php:/usr/local/lib/php') in /home/.showoff/linuxfaqs/linux-faqs.com/HOWTO/Bash-Prompt-HOWTO/c583.php on line 34

Warning: include() [function.include]: URL file-access is disabled in the server configuration in /home/.showoff/linuxfaqs/linux-faqs.com/HOWTO/Bash-Prompt-HOWTO/c583.php on line 35

Warning: include(http://www.linux-faqs.com/HOWTO/header.bottom.inc) [function.include]: failed to open stream: no suitable wrapper could be found in /home/.showoff/linuxfaqs/linux-faqs.com/HOWTO/Bash-Prompt-HOWTO/c583.php on line 35

Warning: include() [function.include]: Failed opening 'http://www.linux-faqs.com/HOWTO/header.bottom.inc' for inclusion (include_path='.:/usr/local/php5/lib/php:/usr/local/lib/php') in /home/.showoff/linuxfaqs/linux-faqs.com/HOWTO/Bash-Prompt-HOWTO/c583.php on line 35
 
FAQS
» Advanced Routing & Traffic Control
» General FAQ
» Squid Proxy Server
» Sendmail
» Fetchmail
» Postfix
» Connecting Mobile Phone
» Paging from Linux
» Standard Commands
» Some common terms
HOW-TOs
» ADSL Bandwidth Management
» Compile Apache
» Make a Bootdis
» Linux-Windows9x-Grub
» Linux-Windows
» Linux Crash Recovery
» Optimise Squid
» Block websites in Squid
» broadcast webcam in linux
» Compile RedHat Linux kernel
» Implement Firewall Security
» Increase Harddrive Performance
» Mount NTFS filesystem
» Patch / rebuild SRPM
» Secure Linux
» Set up a DHCP Server
» Set up an FTP server
» Set up Linux as a Router
» Use Cron
Miscellaneous
» All Ports
» Hardware Guides
» Hardware Review Guides
» Fav Troubleshooting forums
» Spammers fetch email addresses
» Mounting NTFS in linux


 

Chapter 7. Special Characters: Octal Escape Sequences

Outside of the characters that you can type on your keyboard, there are a lot of other characters you can print on your screen. I've created a script to allow you to check out what the font you're using has available for you. The main command you need to use to utilize these characters is "echo -e". The "-e" switch tells echo to enable interpretation of backslash-escaped characters. What you see when you look at octal 200-400 will be very different with a VGA font from what you will see with a standard Linux font. Be warned that some of these escape sequences have odd effects on your terminal, and I haven't tried to prevent them from doing whatever they do. The linedraw and block characters that are used heavily by the Bashprompt project are between octal 260 and 337 in the VGA fonts.

#!/bin/bash

#   Script: escgen

function usage {
   echo -e "\033[1;34mescgen\033[0m <lower_octal_value> [<higher_octal_value>]"
   echo "   Octal escape sequence generator: print all octal escape sequences"
   echo "   between the lower value and the upper value.  If a second value"
   echo "   isn't supplied, print eight characters."
   echo "   1998 - Giles Orr, no warranty."
   exit 1
}

if [ "$#" -eq "0" ]
then
   echo -e "\033[1;31mPlease supply one or two values.\033[0m"
   usage
fi
let lower_val=${1}
if [ "$#" -eq "1" ]
then
   #   If they don't supply a closing value, give them eight characters.
   upper_val=$(echo -e "obase=8 \n ibase=8 \n $lower_val+10 \n quit" | bc)
else
   let upper_val=${2}
fi
if [ "$#" -gt "2" ]
then 
   echo -e "\033[1;31mPlease supply two values.\033[0m"
   echo
   usage
fi
if [ "${lower_val}" -gt "${upper_val}" ]
then
   echo -e "\033[1;31m${lower_val} is larger than ${upper_val}."
   echo
   usage
fi
if [ "${upper_val}" -gt "777" ]
   then
   echo -e "\033[1;31mValues cannot exceed 777.\033[0m"
   echo
   usage
fi

let i=$lower_val
let line_count=1
let limit=$upper_val
while [ "$i" -lt "$limit" ]
do
   octal_escape="\\$i"
   echo -en "$i:'$octal_escape' "
   if [ "$line_count" -gt "7" ]
   then 
      echo
      #   Put a hard return in.
      let line_count=0
   fi
   let i=$(echo -e "obase=8 \n ibase=8 \n $i+1 \n quit" | bc)
   let line_count=$line_count+1
done
echo

You can also use xfd to display all the characters in an X font, with the command xfd -fn <fontname> . Clicking on any given character will give you lots of information about that character, including its octal value. The script given above will be useful on the console, and if you aren't sure of the current font name.


 
Warning: include() [function.include]: URL file-access is disabled in the server configuration in /home/.showoff/linuxfaqs/linux-faqs.com/HOWTO/Bash-Prompt-HOWTO/c583.php on line 254

Warning: include(http://www.linux-faqs.com/HOWTO/body.right.inc) [function.include]: failed to open stream: no suitable wrapper could be found in /home/.showoff/linuxfaqs/linux-faqs.com/HOWTO/Bash-Prompt-HOWTO/c583.php on line 254

Warning: include() [function.include]: Failed opening 'http://www.linux-faqs.com/HOWTO/body.right.inc' for inclusion (include_path='.:/usr/local/php5/lib/php:/usr/local/lib/php') in /home/.showoff/linuxfaqs/linux-faqs.com/HOWTO/Bash-Prompt-HOWTO/c583.php on line 254


 

Warning: include() [function.include]: URL file-access is disabled in the server configuration in /home/.showoff/linuxfaqs/linux-faqs.com/HOWTO/Bash-Prompt-HOWTO/c583.php on line 259

Warning: include(http://www.linux-faqs.com/HOWTO/footer.inc) [function.include]: failed to open stream: no suitable wrapper could be found in /home/.showoff/linuxfaqs/linux-faqs.com/HOWTO/Bash-Prompt-HOWTO/c583.php on line 259

Warning: include() [function.include]: Failed opening 'http://www.linux-faqs.com/HOWTO/footer.inc' for inclusion (include_path='.:/usr/local/php5/lib/php:/usr/local/lib/php') in /home/.showoff/linuxfaqs/linux-faqs.com/HOWTO/Bash-Prompt-HOWTO/c583.php on line 259