shell---practice4
#!/bin/bash#File: dir.sh
#Date:2016-01-14
echo `date` //显示时间
dir='/tmp/lstest' //将目录赋值给变量
if [ ! -d $dir ] ; then //判断目录,不存在就创建
mkdir -p $dir
else
echo "This dir is exist."
fi
cd /tmp/lstest && mkdir ald b56e 6test && touch xy x2y 732 //创建目录与文件
if [ $? -eq 0 ] ; then
echo "Dirs and files set ok."
else
echo "Something error!"
fi
ls * //列出当前目录下以a,x或者6开头的文件或目录
ls [[:alpha:]][[:digit:]]* //列出以字母开头,后跟任意长度字符的文件或目录
页:
[1]