Bold 1 word in a shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bold 1 word in a shell script
# 1  
Old 03-01-2010
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.

Code:
echo -n "Please read a number"
read num ; echo "${bold} $num ${offbold}"

Thank you,
Ccccc
# 2  
Old 03-01-2010
For this to work the shell variables "${bold}" and "${offbold}" would need to contain the control codes which cause your terminal to turn on/off bold type. They are not commands.
# 3  
Old 03-01-2010
Do you mean something such as this?

Code:
bold=`tput smso`
offbole=`tput rmso`
read num ; echo "${bold} $num ${offbold}"


Last edited by Scott; 03-01-2010 at 08:45 PM.. Reason: Code tags
# 4  
Old 03-01-2010
Handy little link: bourne shell snippets
# 5  
Old 03-01-2010
smso changes the background on mine. I just did this in a script a few days ago and used "tput bold" and "tput sgr0" to turn it back to normal. I don't know what the difference is, I just ran across the commands somewhere and tried them.
Code:
echo "notbold $(tput bold) bold $(tput sgr0) notbold"

I made a little script to show me all the colors. Here is the output (png image) with examples of all the colors I had at the time.
Image
# 6  
Old 03-02-2010
Dear Friend,

You can use the following.
Example
Code:
 
  echo -e "\e[1;01mThis is bold text.\e[0m"

Another Example
Code:
echo  "Please read a number"
read num
echo $num;
echo -e "\e[1;01m $num \e[0m"

If you want more details see the following URL

http://webhome.csc.uvic.ca/~sae/seng...ng-colors.html
# 7  
Old 03-02-2010
Bug

Hi,

Using the following program you can display the bold number.

Code:
tput clear
echo -n "Enter the number:"
read num
echo "Number with bold"
echo "----------------"
tput bold
echo "$num"
tput reset


Last edited by pludi; 03-02-2010 at 06:55 AM.. Reason: code tags, please...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

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... (5 Replies)
Discussion started by: ronitreddy
5 Replies

2. Shell Programming and Scripting

Shell Script @ Find a key word and If the key word matches then replace next 7 lines only

Hi All, I have a XML file which is looks like as below. <<please see the attachment >> <?xml version="1.0" encoding="UTF-8"?> <esites> <esite> <name>XXX.com</name> <storeId>10001</storeId> <module> ... (4 Replies)
Discussion started by: Rajeev_hbk
4 Replies

3. Shell Programming and Scripting

Search for the word and exporting 35 characters after that word using shell script

I have a file input.txt which have loads of weird characters, html tags and useful materials. I want to display 35 characters after the word "description" excluding weird characters like $&lmp and without html tags in the new file output.txt. Help me. Thanx in advance. I have attached the input... (4 Replies)
Discussion started by: sachit adhikari
4 Replies

4. Shell Programming and Scripting

Search for the word and exporting 35 characters after that word using shell script?

I have a file input.txt which have loads of weird characters, html tags and useful materials. I want to display 35 characters after the word description excluding weird characters like $$#$#@$#@***$# and without html tags in the new file output.txt. Help me. Thanx in advance. My final goal is to... (11 Replies)
Discussion started by: sachit adhikari
11 Replies

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

6. Shell Programming and Scripting

how to convert a shell script to a php script for displaying next word after pattern match

I have a shell script which I made with the help of this forum #!/bin/sh RuleNum=$1 cat bw_rules | sed 's/^.*-x //' | awk -v var=$RuleNum '$1==var {for(i=1;i<=NF;i++) {if($i=="-bwout") print $(i+3),$(i+1)}}' Basically I have a pages after pages of bandwidth rules and the script gives... (0 Replies)
Discussion started by: sb245
0 Replies

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

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

9. Shell Programming and Scripting

bold the word in report

I hv script that will output a txt file report , the report content is as below, I would like the word "No error" is bolded so that this message is highlighted , can advise what can i do ? thx Date : 2002-01-22 Error : No error (3 Replies)
Discussion started by: ust
3 Replies

10. Shell Programming and Scripting

Can a shell script pull the first word (or nth word) off each line of a text file?

Greetings. I am struggling with a shell script to make my life simpler, with a number of practical ways in which it could be used. I want to take a standard text file, and pull the 'n'th word from each line such as the first word from a text file. I'm struggling to see how each line can be... (5 Replies)
Discussion started by: tricky
5 Replies
Login or Register to Ask a Question