1757454 Members
2703 Online
108862 Solutions
New Discussion юеВ

Re: Some script syntax

 
Ngoh Chean Siung
Super Advisor

Some script syntax

Hi,

echo "Press [Y]/[y] to continue, [Enter] to quit \c"
read ans rest
if [ -z "$ans" ]
then
exit
fi

Above is part of the script.
1) what is \c for?
2) what is rest for?
3) what is -z for?

regards.
3 REPLIES 3
Trond Haugen
Honored Contributor

Re: Some script syntax

1) Supress return
(Will leave the cursoe after "quit")
2) "Garbage collector".
If user types other words after "y"
3) Test if zero = enter/return

Regards,
Trond
Regards,
Trond Haugen
LinkedIn
Bharat Katkar
Honored Contributor

Re: Some script syntax

Hi,

1. if you specify \c then the ouput will be like:

Press [Y]/[y] to continue, [Enter] to quit

if \c is not specified then:
Press [Y]/[y] to continue, [Enter] to quit


3. -z is to see whether user simply pressed ENTER key that mean he entered nothing and the string length is zero so it's time quit.

Hope that helps.
Regards,



You need to know a lot to actually know how little you know
Steve Steel
Honored Contributor

Re: Some script syntax

Hi


I am not going to repeat the explanations already given but if you need a good source for script info


http://www.shelldorado.com/




Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)