读行

#!/bin/bash
#AUtor : gaohuina
#date: 2011-01-14
#DESC :
let LINENUME=0
while getopts ":n" SWITCH; do
  case $SWITCH in
  n)
   let LINENUME=1
    ;;
  \?) echo " no line"
    exit 1
  ;;
  esac
done
shift $[$OPTIND-1]
  let i=1
 while read line; do
if [ $LINENUME -eq 1 ]; then
  echo "$i $line"
 let i++
 else
  echo "$line"
fi
done < $1
 

你可能感兴趣的:(职场,休闲,OPTIND)