Open a post and start learning shell programming

Source: Internet
Author: User

Well, that's how it started.

First of all, this little episode ... It was written, it collapsed, and then I collapsed ... Crash I looked everywhere for a tool that would not let me collapse, and then find out to find the ScribeFire.

1. Take parameters from command line

~ Shell Built in Variables ~ meaning
$# Number of command line arguments.
$? Exit Status
$* String that contains all arguments to shell
[Email protected] Same as above, except when quoted.
$- Option supplied to Shell
$$ PID of Shell
$! PID of last started background process (started with &)

In addition, there are $1,$2,$3 ... represents a low n parameter.

2. About square brackets

This cargo is a function! It's not a sign! Not a sign! It is equivalent to the test command, that bar, if you do not give it the entire space what, wait for the error, the interpreter will tell you can not find the symbol AH ah.

#!/bin/sh# #Script to test if: Elif...elseif [$#-eq 0]thenecho "$0:you must give one integers!" Exit 1fiif [$1-gt 0]then        echo "$ is positive" elif [$1-lt 0]then        echo "$ is negative" elif [$1-eq 0]then< C5/>echo "$1-eq 0" Else        echo "opps! $ not number, give number please! " Fi
Remember ' [' To add a space, '] ' before the space Ah ah ah.
There is a prior release:
Source
http://linux.vbird.org/linux_server/0250simple_firewall.php
http://tille.garrels.be/training/bash/
Http://freeos.com/guides/lsst/index.html
Http://www.hlevkin.com/Shell_progr/hellobash.htm
http://www.cyberciti.biz/faq/bash-for-loop/
Http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
Http://www.ibm.com/developerworks/linux/library/l-bash/index.html

Open a post and start learning shell programming

Related Article

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.