Ksh programming considerations

Source: Internet
Author: User

1) ksh in unix is different from ksh in linux, while the information on google is basically for ksh in linux.

For example, the for loop under unxi cannot be written in this way.

For I in {1 .. 10}; do

 

But like this:

I = 1 <br/> while [[$ I lt 10]; do <br/> I =$ ($ I + 1) <br/> done

 

2) The equal signs of the assignment statement cannot contain spaces on both sides.

 

3) You can directly use $ (expression) instead of expr for variable calculation ))

 

4) the return value of Sqlplus may contain a line break. set pagesize 0 heading off feedback off verify off must be forced.

For example:

#! /Bin/ksh <br/> return_var = 'sqlplus-s scott/tiger @ ora_db <EOF <br/> set pagesize 0 heading off feedback off verify off <br/> select username from users where userid = 1; <br/> EOF '</p> <p> if ["$ return_var" = "Tom"]; then <br/> echo "YES" <br/> fi </p> <p> echo "-----------------" <br/> echo "mm $ {return_var} adbd" <br /> echo "-------------------" <br/>

Screen output

YES

-------------------

MmTomadbd

-------------------

 

If set pagesize 0 is not added, the screen output is

-------------------

Mm

Tomadbd

-------------------

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.