练习1:输入一个数,实现倒叙123-》321
练习2:输入一个,判断是否是素数
练习3:输入一个文件名,
判断是否在家目录下存在,
如果是一个目录,则直接输出是目录下的sh文件的个数
如果存在则判断是否是一个普通文件,如果是普通文件则判断是否具备
可读可写可执行权限,如果具备权限,写入helo.不具备权限,则添加读写执行权限,写入hello
#!/bin/bashread -p "请输入文件名:" a
if [ -e $a ] #默认是家目录下
thenecho "$a存在"#if [ -b $a ]thenecho "块设备文件"if [ -r $a ]thenecho -n "r"elseecho -n "-"fiif [ -w $a ]thenecho -n "w"elseecho -n "-"fiif [ -x $a ]thenecho -n "x"elseecho -n "-"fi#elif [ -c $a ]thenecho "字符文件"if [ -r $a ]thenecho -n "r"elseecho -n "-"fiif [ -w $a ]thenecho -n "w"elseecho -n "-"fiif [ -x $a ]thenecho -n "x"elseecho -n "-"fi#elif [ -d $a ]thenecho "目录文件"if [ -r $a ]thenecho -n "r"elseecho -n "-"fiif [ -w $a ]thenecho -n "w"elseecho -n "-"fiif [ -x $a ]thenecho -n "x"elseecho -n "-"fi#elif [ -L $a ]thenecho "软链接文件"if [ -r $a ]thenecho -n "r"elseecho -n "-"fiif [ -w $a ]thenecho -n "w"elseecho -n "-"fiif [ -x $a ]thenecho -n "x"elseecho -n "-"fi#elif [ -S $a ]thenecho "套接字文件"if [ -r $a ]thenecho -n "r"elseecho -n "-"fiif [ -w $a ]thenecho -n "w"elseecho -n "-"fiif [ -x $a ]thenecho -n "x"elseecho -n "-"fielif [ -p $a ]thenecho "管道文件"if [ -r $a ]thenecho -n "r"elseecho -n "-"fiif [ -w $a ]thenecho -n "w"elseecho -n "-"fiif [ -x $a ]then echo -n "x"elseecho -n "-"fielif [ -f $a ]thenecho "普通文件"if [ -r $a ]thenecho -n "r"elseecho -n "-"fiif [ -w $a ]then echo -n "w"elseecho -n "-"fiif [ -x $a ]thenecho -n "x"elseecho -n "-"fifi
elseecho "$a不存在"
fi
练习4:输入一个字符串,实现字符串逆置