|
//mytar.sh -- a sample script:
#!/bin/bash
if [ "${1##*.}" = "tar" ]
then
echo This appears to be a tarball.
else
echo At first glance, this does not appear to be a tarball.
fi
然后给mytar.sh加上可执行属性:
$chmod 755 mytar.sh
运行该脚本:
$ ./mytar.sh thisfile.tar
提示出错:
./mytar.sh: line 3 : if [ tar = tar ]: command not found
./mytar.sh: line 4 : syntax error near unexpeced token `then'
./mytar.sh: line 4 : `then'
这个例子出自Daniel Robbins 的
《Bash by example, Part 1 Fundamental programming in the Bourne again shell (bash)》
http://www-106.ibm.com/developerworks/library/l-bash1.html |
|