why


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting why
# 1  
Old 05-26-2007
why

Why it prints out like this

root$ echo '\n\t'"No disk capacity more than 80%" '\n'
\n\tNo disk capacity more than 80% \n #result

I don't know what happen, if u know please tell me why and how to solve it
# 2  
Old 05-26-2007
The problem is that you are using a poor shell. Fix the problem by switching to a better shell.

Code:
$ ksh
$ echo '\n\t'"No disk capacity more than 80%" '\n'

        No disk capacity more than 80%

$ csh
%echo '\n\t'"No disk capacity more than 80%" '\n'
\n\tNo disk capacity more than 80% \n
%

See? It works when I use ksh and it fails with csh.
# 3  
Old 05-26-2007
Hi.

I would discourage the use of (t)csh for scripting, but if you must use it, you could try using the non-built-in echo:
Code:
#!/bin/csh

# @(#) s1       Demonstrate stand-alone echo.

echo
echo $version | fmt
echo

echo -e '\n\t' "No disk capacity more than 80%" '\n'

/bin/echo -e '\n\t' "No disk capacity more than 80%" '\n'

exit 0

which produces:
Code:
% ./s1

tcsh 6.13.00 (Astron) 2004-05-19 (i386-intel-linux) options
8b,nls,bye,al,ng,rh,nd,color,filec

-e \n\t No disk capacity more than 80% \n

         No disk capacity more than 80%

and also:
Quote:
echo [-n] word ...
Writes each word to the shell's standard output, separated by
spaces and terminated with a newline. The echo_style shell
variable may be set to emulate (or not) the flags and escape
sequences of the BSD and/or System V versions of echo; see
echo(1).

-- excerpt form man tcsh
cheers, drl
# 4  
Old 05-27-2007
MySQL

Thank u for your help !!!
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question