Bold Characters


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bold Characters
# 15  
Old 10-20-2009
Okay, got it. That is just the printf syntax that doesn't support the "\e" shortcut.

This will work on older AIX, Solaris or anything:
Code:
printf "\033[1mbold\033[0m"

# 16  
Old 10-21-2009
[indent]
The tput command is only required (by the POSIX standard) to support three operands, clear, init and reset. You cannot count on anything beyond that.

Most do support a lot more, but there are two different versions. One uses the termcap database, the other uses terminfo. The commands are not the same; what works on one does not always work on the other.

On one system I use, "tput smso; echo qwerty; tput rmso" will print 'qwerty' in reverse; on another, it is unchanged.

Last edited by cfajohnson; 10-21-2009 at 02:52 PM..
# 17  
Old 10-21-2009
Quote:
Originally Posted by cfajohnson
"terminals that do not support it are few and far between"

This is the code to use:

Code:
printf "\e[1m"  ## bold on
printf "\e[0m"  ## bold (and other attributes) off

I use a terminal emulator called Token2Shell when logging into my linux server from my XP laptop. This code does not work with it, I certainly see nothing in bold.

However the initial tput statements at the head of this post do work.

Code:
bold=`tput smso`
offbold=`tput rmso`

# 18  
Old 10-21-2009
Interesting. Please post the output of
Code:
bold=`tput smso`
offbold=`tput rmso`
echo "${bold}" | hexdump -C
echo "${offbold}" | hexdump -C

so we can figure out what weird terminal it thinks it is Smilie

...did you try the \033 syntax, instead of \e? Non-ANSI terminals are extremely rare these days...

Last edited by Corona688; 10-21-2009 at 07:40 PM..
# 19  
Old 10-23-2009
OK

Nothing appeared as bold with this: -

Code:

poweredge:/home/brad>bold=`tput smso`
poweredge:/home/brad>offbold=`tput rmso`
poweredge:/home/brad>echo "${bold}" | hexdump -C
00000000 1b 5b 37 6d 0a |.[7m.|
00000005
poweredge:/home/brad>echo "${offbold}" | hexdump -C
00000000 1b 5b 6d 0a |.[m.|
00000004

This does not print bold either: -
Code:
 
poweredge:/home/brad>printf "\033[1mbold\033[0m\n"
bold

I said this does print bold but on reflection I may be wrong, when I tried it tonight the word bold was inverted with its background although I was sure it printed bold the other night. Do you think the previous statements could have changed the behaviour?: -

Code:
 
poweredge:/home/brad>offbold=`tput rmso` 
poweredge:/home/brad>bold=`tput smso` 
poweredge:/home/brad>echo "This word is ${bold}bold${offbold} and this is not"
This word is bold and this is not

I don't know what to make of the hexdump so would be glad for an explanation of what it means.

Token2Shell is a funny little terminal emulator that does not seem to let you set the terminal type.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Need help getting rid of bold characters

Hi! So i've got this shell script that asks questions and the user is required to input answers. The answers typed are bold. sh-*.*$ sh filename dir cat question tput bold read ans tput sgr0 ... and so on tput sgr0 exit So when the script ends i don't get the bold characters... (3 Replies)
Discussion started by: Kingzy
3 Replies

2. Shell Programming and Scripting

Making Some Characters in file BOLD

Hi All, I want to make some characters to be bold in a file. I have a file e.g aa.log which contains rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr gfgfgdaerqrqwrqerqwrwqwrqrqwrqr qqwerqwrqwrqwrqwrqwrqwrqwrq qwrqwrqwrqwrqwrqwrqwrqwrqwr File is too large to view Last line... (2 Replies)
Discussion started by: rajeshorpu
2 Replies

3. Shell Programming and Scripting

how to display in bold

Hi, i am using mailx option to send mail from unix In the body of the mail i want certain numbers to be displayed in bold Is there any way to do it If so, can anyone help me in this regard. (2 Replies)
Discussion started by: trichyselva
2 Replies

4. Shell Programming and Scripting

Bold characters in a file using Shell script

Hi, When I am running below mentioned script then the characters become bold but after opening the same file in Windows, Instead of getting bold characters i am getting some garbage value for \033Kunal Dixit Output in Windows (after ftp the file): but in windows , i am getting My name is... (0 Replies)
Discussion started by: kunal_dixit
0 Replies

5. UNIX and Linux Applications

Bold characters in mail

I sh, I have bold characters in a file and I want to mail file to an ID. $cat file Incorrect or invalid external email IDs in TO and CC list for email_rules: If I pass this file to mailx $ cat file | mailx -s "hi" abc@xyz.com What I get in mail is  (8 Replies)
Discussion started by: hemangi13
8 Replies

6. Shell Programming and Scripting

Bold characters in c shell

Hi, Can someone tell me how to display characters in Bold in C shell?? (9 Replies)
Discussion started by: hemangi13
9 Replies

7. Shell Programming and Scripting

color,bold

hi friend , I am generating a csv file i,e output file E104|0|06/04/1994|The values E005 and E001 are not equal. E106|0|01/09/1993|The values E001 and E002 are not equal. E106|0|01/09/1993|The values E003 and E002 are not equal. E108|0|02/30/1995|The values R001 and E001 are not equal.... (0 Replies)
Discussion started by: charandevu
0 Replies

8. Programming

Bold text

hello, how do i display the text in the printf statement in bold. or is there anyway to display the text on the console in bold thx in advance svh (3 Replies)
Discussion started by: svh
3 Replies

9. UNIX for Dummies Questions & Answers

Printing in Bold

Hi, How do I print some shell variable in BOLD/ Thanks for any suggestions, Preeti (10 Replies)
Discussion started by: preetikate
10 Replies

10. Shell Programming and Scripting

Bold the paragraph

Hi, I have a file with multiple paragraph. I want to look for some word and make that paragraph bold. How can I do that? Thanks, Karthik (3 Replies)
Discussion started by: caprikar
3 Replies
Login or Register to Ask a Question