shellの台本を読む
1755 ワード
Linuxにはshellのスクリプトがたくさんあります。shellのシナリオを読んで、linuxや他のソフトウェアを理解するのに役立ちます。
しかし、shellの文法とjavaはかなり違っています。彼の文法を知る必要があります。
しかし、shellの文法とjavaはかなり違っています。彼の文法を知る必要があります。
1 $# $0 $1 ${2} , , 1, 2
2 if [ 1 -eq 1 ] ; then echo eq; fi
if [ -f t.sh ] ; then echo file exist; fi
if [ -f "t.sh" ] ; then echo "file exist"; fi
[ -x "/bin/ls" ] : /bin/ls
[ -n "$var" ] : $var , true
[ "$a" = "$b" ] : $a $b
3、
case ... in
...) do something here ;;
esac
case "${1}" in
--help | -h | --h* )
echo "${USAGE}" >&2
exit 0
;;
--version | -V )
echo "${VERSION}" >&2
exit 0
;;
*)
echo "nothing" >&2
esac
4
for a in A B CC ; do echo $a; done
for a in * ; do echo $a; done --
$ for a in /d/kankan/* ; do echo $a; done
/d/kankan/ _160998_457944.xv
/d/kankan/ 3__ : _187183_1347943.xv
/d/kankan/ __2012-05-25 _166148_372981.xv
[]
1、
str1 = str2 、
str1 != str2 str1 str2
-n str1 0 ( )
-z str1 0 ( )
str1 str1
2、
int1 -eq int2
int1 -ne int2
int1 -gt int2 int1 int2
int1 -ge int2 int1 int2
int1 -lt int2 int1 int2
int1 -le int2 int1 int2
3、
-r file
-w file
-x file
-f file
-d file
-c file
-b file
-s file 0
-t file ( 1)
4、
-a
-o
!
, SHELL , 。
function f(){ echo this$*; }
f 8 9