分类:
2009-08-07 12:26:40
#!/bin/sh
if [ $# -gt 1 ]; then
echo "Usage: $0
[FileName]"
exit 1
elif [ $# -eq 1 ];
then
MY_FILE=$1
else
MY_FILE=$0
fi
if [ ! -f $MY_FILE ];
then
echo "$MY_FILE does not exist!"
exit
2
fi
MY_LINE_NO=1
while read MY_LINE
do
printf "%5.5d:
$MY_LINE\n" $MY_LINE_NO
MY_LINE_NO=$((MY_LINE_NO+1))
done < $MY_FILE
在来个例子
#!/bin/bash