FIRST:control structure
1 CONDITION--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 <
阅读(9) | 评论(0) | 转发(0) |
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
1 CONDITION--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 <
相关热门文章
给主人留下些什么吧!~~
评论热议