我是一个初学者,照着书上的程序也写不对,大家帮看看哪里出错了?怎么改?
代码如下: (ifmkdir)
____________________________________________________________________
#!/bin/bash
#ifmkdir
DIR_NAME=testdirec
#where are we?
THERE='pwd' [是不是这里出错?]
#send all output to the system dustbin
mkdir $DIR_NAME > /dev/null 2>&1
#is it a directory ?
if [ -d $DIR_NAME ]; then
#can we cd to the directory?
cd $DIR_NAME
if [ $?=0 ]; then
#yeah we can
HERE='pwd' [是不是这里出错?]
cp $THERE/*.txt $HERE
else
echo "Cannot cd to $DIR_NAME" >&2
exit 1
fi
else
echo "Cannot creat directory $DIR_NAME" >&2
exit 1
fi
_____________________________________________________________
运行./ifmkdir后出现
cp:cannot stat 'PWD/*.txt':No such file or directory.
实际上在当前目录下有txt文件.
谢谢帮忙!:help :help