Print Bold in Shell scripting

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Print Bold in Shell scripting
# 1  
Old 11-16-2015
Print Bold in Shell scripting

I am printing the following and sending it in an email in a bash script.

echo "#RESULTS FOR `date +%c`#" >> File1.txt

My desired output is to print it in bold:
#RESULTS FOR Mon 16 Nov 2015 03:54:20 PM CST#

Is there a way I can have it printed in bold which sends output in a mail. Please do help.

# 2  
Old 11-16-2015
For email, nowadays, if you want it "pretty" you going to send the pretty part as an html encoded block.

Now, that doesn't fix it for shell though.... you might be able to build a filter to translate embedded escapes into something meaningful when printed.

Not much help... but some ideas anyway...
# 3  
Old 11-23-2015
If you store the following values in variable, e.g boldon and boldoff you can do it:-
boldon=`tput smso`
boldoff=`tput rmso`

I might have the wrong bit, this might put on underline or reverse perhaps. I don't have a server to hand to try this on I'm afraid. Can someone correct me if I'm wrong please?

Anyway, you can then use them like this:-
printf "Hello ${boldon}bold${boldoff} world!\n"

I hope that this helps,
This User Gave Thanks to rbatte1 For This Post:
# 4  
Old 11-23-2015
You may find the following to be better (?)

boldon=`tput bold`
boldoff=`tput sgr0`

And Robin, thank you for not suggesting hardcoding terminal escapes!!
# 5  
Old 11-23-2015
       bold=`tput smso` offbold=`tput rmso`
	    Set  the  shell variables bold, to begin stand-out mode sequence, and offbold, to end
	    standout mode sequence, for the current  terminal.

An excerpt from the man pages here:

I didn't see any match for the string sgr -- that might be in man pages for tput in other distributions, systems, etc.

Best wishes ... cheers, drl
This User Gave Thanks to drl For This Post:
# 6  
Old 11-23-2015
Doubtful that Debian got this wrong. tput bold and sgr0 date way before Linux for terminfo. With that said, there are some (and popular too) BSD variants still holding on to termcap.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell Scripting , need to search and print a line that contains a specific pattern

Take example of below file. abc.txt nas1:/abc/test/test1 /test nas1:/abc/test/test1/test2 /test/abc nas1:/abc/test/ Now i have a variable that contains "nas1:/abc/test/test1" value , so i need to search the above file for this variable and print only this line. ... (14 Replies)
Discussion started by: mohit_vardhani
14 Replies

2. Shell Programming and Scripting

Color Underline and Bold letter in shell script

Hi All, This is my first port..... I am using AIX 5L, installed 10g database. On daily basis we takes rman backup. This backup status info strored in a log file. I write a script to know the status of back means I will fire this script and this script will send a mail to me. #!/bin/bash... (16 Replies)
Discussion started by: mcagaurav
16 Replies

3. Web Development

Perl scripting or shell scripting?

i am going to study any one of the scripting languages mentioned above(shell 0r perl scripting) . Which is having more scope for a fresher? (1 Reply)
Discussion started by: Anna Hussie
1 Replies

4. What is on Your Mind?

Shell Scripting vs Perl scripting

Gents, I have been working in a Solaris/Unix environment for about 9 months. I took some linux classses online before getting the job. But, I am not very good at scripting. I want to learn how to script. Do you think that I should start with Shell scripting or Perl? I wanted to continue with... (2 Replies)
Discussion started by: Pouchie1
2 Replies

5. What is on Your Mind?

Shell scripting vs Perl scripting

Hi all, I would like to start developping some good scripting skills. Do you think it would be best to start with shell scripting or Perl? I already got a fundation, really basics, in perl. but I am wondering what would be best to be good at first. Can you please help me determine which one to... (14 Replies)
Discussion started by: Pouchie1
14 Replies

6. Shell Programming and Scripting

Bold 1 word in a shell script

I want to bold one word in shell script. I want the value for num bold when it is inputted. My code does not bold the value. It's like its not even there. echo -n "Please read a number" read num ; echo "${bold} $num ${offbold}" Thank you, Ccccc (6 Replies)
Discussion started by: Ccccc
6 Replies

7. Shell Programming and Scripting

Call Shell scripting from Perl Scripting.

Hi How to call a shell scripting through a Perl scripting? Actually I need some value from Shell scripting and passes in the Perl scripting. So how can i do this? (2 Replies)
Discussion started by: anupdas
2 Replies

8. 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

9. 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

10. Shell Programming and Scripting

difference between AIX shell scripting and Unix shell scripting.

please give the difference between AIX shell scripting and Unix shell scripting. (2 Replies)
Discussion started by: haroonec
2 Replies
Login or Register to Ask a Question

Featured Tech Videos