Chinaunix首页 | 论坛 | 博客
  • 博客访问: 293435
  • 博文数量: 82
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 874
  • 用 户 组: 普通用户
  • 注册时间: 2015-03-21 09:58
个人简介

traveling in cumputer science!!

文章分类

全部博文(82)

文章存档

2016年(13)

2015年(69)

我的朋友

分类: LINUX

2015-03-22 16:36:23

FIRST:control structure
     1CONDITION--if
        The Form: 
        if [ expression ]
            then
                command
        elif [ expression ] 
            then
                command
        ....
        else
                command
        fi 
    For example:
        if [ $# -lt 2 ] 
            then
                echo "Error!Arguments are not enough!"
        elif [ $# -gt 2 ]
            then
                echo "Error!Arguments are too many!"
        else
                echo "Good!U are great!"            
        fi
    Summary:
    (1)operator         meaning
        -eq                  equal to
        -ne                  not equal to
        -lt                    less than
        -le                    less than or equal
        -gt                   great than
        -ge                   great than or equal
    (2)there must be ' ' space at the two side of '[' and ']'

    (3)"if" and "fi" are a pair

    (4)if [ expression ] ;then
        or
        if [ expression ] 
                then
        these two forms are all right!
    2CONDITION--case
        The Form:           
            case word in

                pattern1 )
                    command-list1
                    ;;
                pattern2 )
                    command--list2
                    ;;
                ...
            
esac
        Summary:
            (1)";;" or ";&" or ";;&"
                ";;" carry out the command-list will exit the case structure
                ";&" and ";;&"carry out the command-list will continue matching the next pattern
            (2)
                "case" and "esac" are a pair
            (3)
                the pipe can be used in pattern,for example
                    a|b|c|...)
                        command-list
                        ;; 
    3CIRCULATE--while
        The Form:
            while [ expression ] 
                do
                    command
                done

            or
           while [ expression ] ; do command ; done
    

SECOND:I/O and pipe
    1 OUTPUT
        redirection output operator
            '>' only output the content to the place and the next '>' will cover the content in it.
            '>>' add the output contnet to the place at the end. That is to say it will not cover the content in it .

        the default output is 1; the error information output is 2
        so "1> a" can redirect the standard output to a
             "2> b" can redirection the error output to b
            "&> a" and "1>a 2>&1" and "2>a 1>&2" can output the all content to a
        The Form:
            command > a
            {command1; command2; command3; ...} > a 
            command >> a
            command 1> a 2> b

    2INPUT:
        The Form:
            command < filename


THIRD:quote
1(\)
    Form:
        \(character)
    For example:       
        echo Price:\$2
        then putout: Price:$2
            but not putout the second parameter
2('')
    Form:
        'character string'
    For example:
        echo 'The book <
阅读(979) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~