Need help getting rid of bold characters


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Need help getting rid of bold characters
# 1  
Old 02-03-2010
Question 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.

Code:
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 anymore. But when i end the script 'abruptly' (like i press Ctrl+C during the script usage), or when i type sh filename wrongdir and get the corresponding error messages, i get this:
sh-*.*$

I don't want to type reset whenever it happens; not that i don't like it but i shouldn't be doing it.

In a nutshell, i want everything normal characters as soon as the script closes, whether it was manual exit, error messages, of end of script.

Thanks in advance.

Last edited by pludi; 02-03-2010 at 05:47 PM.. Reason: code tags, please...
# 2  
Old 02-03-2010
Try putting 'trap reset EXIT' at the top of your script. When it gets a trappable signal that forces it to quit, it should run 'reset' and make your terminal sane again before it does so.
# 3  
Old 02-03-2010
Quote:
Originally Posted by Corona688
Try putting 'trap reset EXIT' at the top of your script. When it gets a trappable signal that forces it to quit, it should run 'reset' and make your terminal sane again before it does so.

hey thx alot !!! it actually also solved what would have been my next question.

I also wanted to know how to make my script exit anytime i entered 'exit' without doing nested ifs mumbo jumbo coz i tried that at one point :S

your suggestion fortunately took care of that too Smilie

kudos Smilie
# 4  
Old 02-05-2010
I actually tweaked the command and instead put

Code:
trap "tput sgr0" exit EXIT

as the reset command was too radical Smilie

HTML Code:
https://www.unix.com/unix-dummies-questions-answers/129361-need-help-getting-rid-newlines.html
Solved this one nevermind

Last edited by Kingzy; 02-05-2010 at 06:12 PM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Getting rid of abnormal Characters

i'm grepping for words in the /var/adm/messages (sun solaris). but it looks like while my grepping finds the strings, when it outputs them out, the beginning of some lines are chopped off. Jun 13 14:06:02 sky.net ufs: NOTICE: alloc: /prod: file system full 3 14:39:19 sky.net ufs: NOTICE:... (1 Reply)
Discussion started by: SkySmart
1 Replies

2. Shell Programming and Scripting

get rid of non-alphanumeric characters

Hi! Could anyone so kindly help me a code to eliminate from a txt file, obtained by collecting and merge several web-page, every word (string) containing non alphabetical, numeric and punctuation character (i.e NON a-zA-Z0-9, underscore and punctuation mark)? Thanks a lot for the help to... (5 Replies)
Discussion started by: mjomba
5 Replies

3. Shell Programming and Scripting

Getting rid of non-numeric and non-characters

I have a database script that always produces the following output: 0 btw, the unwanted character looks like a square on a unix system. it doesn't look like the above quote. how can I get rid of it and only keep the "0"? ---------- Post updated at 01:57 PM ---------- Previous update was... (2 Replies)
Discussion started by: SkySmart
2 Replies

4. Shell Programming and Scripting

Bold Characters

Hi All, How to make the characters bold in k shell. like for example "File is too large to view" to "File is too large to view" is it like echo "File is too large to view" Please advice and samples (18 Replies)
Discussion started by: rajeshorpu
18 Replies

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

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

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

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. UNIX and Linux Applications

get rid of special characters

Hi Friends, we have recently installed RHEL4.4 and when i give the commd ls -l > tt it prints the file name with some special charactes like ^[[00m1 in the begining of the file name and at the end of the file name. I wanted to use the file names of removing it before taking the backup and... (4 Replies)
Discussion started by: vakharia Mahesh
4 Replies

10. UNIX for Dummies Questions & Answers

getting rid of control characters

how can i get rid of the control characters , ex. ^M, ^G, in a file? thanks... (2 Replies)
Discussion started by: apalex
2 Replies
Login or Register to Ask a Question