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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

turning off verbose mode in bash scripting

Status
Not open for further replies.

keto

Technical User
Aug 10, 2001
3
AU
Hello Everyone,
I'm having a problem with using the escape character effectively. I'm running RedHat 6.2 and I am trying to write scripts using the bash shell.
Whenever I type \n to start a new line, it actually prints it out in the script, the same goes for \c. I have been told that I might be in verbose mode and that the command: unset -v should fix it. But that doesn't seem to work.
Can any body help me please.
Thanks
Keto
 
Try putting a $ in front of the single quoted expresion.

E.G: echo $'Hello\nWorld'

This should print
Hello
World

From the bash man pages:

Words of the form $'string' are treated specially. The word expands to string, with backslash-escaped characters replaced as specifed by the ANSI C standard. Backslash escapes equences, if present, are decoded as follows:
\a alert (bell)
\b backspace
\e an escape character
\f form feed
\n new line
\r carriage return
\t horizontal tab
\v vertical tab
\\ backslash
\' single quote
\nnn the character whose ASCII code is the octal value nnn( one to three digits)
 
Just as a follow-up. The problem was an argument for the echo program ie. the -e argument which evaluates escaped characters on red-hat systems and is unset by default.

Hence I fixed this by: alias echo = "echo -e"

Thanks anyway
Keto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top