D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] Long bash scripts

 

On Monday 24 January 2005 6:06 pm, Neil Williams wrote:
How would the script be written to accept command line arguments to jump to
that line?

Found it:

#!/bin/bash
usage="-j<int> jump to line number <int>"
while getopts ":j:" options; do
case $options in
  j ) jump=$OPTARG;;
  h ) echo $usage;;
  \? ) echo $usage
       exit 1;;
  * ) echo $usage
       exit 1;;
 esac
done
if [ $jump ]
then
       echo Jumping to line $jump
else
       echo jump not specified
fi

-- 

Neil Williams
=============
http://www.dcglug.org.uk/
http://www.nosoftwarepatents.com/
http://sourceforge.net/projects/isbnsearch/
http://www.williamsleesmill.me.uk/
http://www.biglumber.com/x/web?qs=0x8801094A28BCB3E3

Attachment: pgp00071.pgp
Description: PGP signature