Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RE: thread822-1262729

Status
Not open for further replies.

newu

Technical User
Oct 11, 2006
2
US
There were two categories of responses in this thread, and I have questions about both:

1) feherke suggested echo -e "\033[1mtest .................

--I tried this, and it works in the terminal, but not if I direct the output to a file. Is that to be expected?

--What is the origin of \033{1m....\033[0m; are there variations that would
cover underlining, color, etc.? If so, where would I find them?

2) Many responses involved "tput," but there are some basic things I don't understand. For example, exactly how are

bold=`tput smso`
offbold=`tput rmso` (or whatever)

entered? If I just type these and press return, of course I get a "command not found" response -- which isn't useful. Simply, I don't know how to enter something so that it won't be viewed as a command. Or are these, somehow, commands?

TIA
 
These are "ANSI Terminal Codes". They come from back in the day when you communicated with the computer via a character terminal (no graphics) that was usually something like 80 characters wide and 24 or 25 lines high. These codes, which were very specific to the terminal being used, would do things like position the cursor, bold the characters, and all kinds of low tech effects.

Just Google for "ANSI terminal codes" and you'll get all kinds of info, including the lists of "Escape Sequences".

Here's one for VT100 terminals...

 
If you're getting "Command not found", your PATH probably isn't set up correctly. On my system "tput" is in "/bin". Try adding "/bin" to your PATH, or by typing "/bin/tput" to use it.

Try "man tput" and "man terminfo" for more information.
 
Oddly are you still trying to add colour/bold/italics to your emails ?

1) feherke suggested echo -e "\033[1mtest .................

--I tried this, and it works in the terminal, but not if I direct the output to a file. Is that to be expected?
This is to be expected, these codes make the physical terminal behave in a specific manner, if you want bold text in a text file, you will (most probably) be disappointed [ unless its a file displayed in either a) a web browser, b) an email client or c) its a rich text document.


2) Many responses involved "tput," but there are some basic things I don't understand. For example, exactly how are

bold=`tput smso`
offbold=`tput rmso` (or whatever)

entered? If I just type these and press return, of course I get a "command not found" response -- which isn't useful. Simply, I don't know how to enter something so that it won't be viewed as a command. Or are these, somehow, commands?

if you type in bold=`tput smso`, this sets a local variable ($bold) to have the output value of the command tput smso.
You could after entering this (provided you dont get a command not found message) enter the following: echo $bold.

if you then typed in echo "hello" you should see hello.

Al of this is only relevent to the physical terminal screen you are working on, and would not be visible to anyone viewing any kind of output from you n the form of a text file (well its highhly unlikely anyway).







______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top