交互式让用户输入一个文件路径,判断文件是否存在,若存在判断文件类型,若文件是普通文件,不能使用wc。...

突然发现查看文件行数的那个脚本老师要求的是不让用wc命令,呵呵,再补充一个脚本:
#!/bin/bash 1let count=0 2read -p "please input a file:" A 3if ! test -e $A &> /dev/null ; then 4echo "wrong" 5exit 0 6eliftest -f $A &>/dev/null ; then 7echo "$A is right" 8echo "line is:" 9while read $B ; do 10count=$((count+1)) 11done <$A 12echo"$count" 13elif test -d $A &> /dev/null ; then 14echo "$A is a dir" 15fi 【交互式让用户输入一个文件路径,判断文件是否存在,若存在判断文件类型,若文件是普通文件,不能使用wc。...】转载于:https://blog.51cto.com/newyorks/467327

    推荐阅读