shell 判断文件是否存在 并且 循环读取
#!/bin/sh
if [ $# -gt 1 ]; then 空格也要注意
echo "Uage: $0[FileName]"
exit 1
elif [ $# -eq 1 ]; then
myFileName=$1
echo $myFileName
else
myFileName=$0
echo "/home/hadoop/"$myFileName
fi
if [ ! -f"$file" ];then //!和-f 之间要有空格
echo "$myFileName does not exit!"
exit 1
fi
MY_LINE_NO=1
while read MY_LINE
do
echo "$MY_LINE:$MY_LINE_NO"
MY_LINE_NO=$((MY_LINE_NO+1))
done<$myFileName