Einstein47
Programmer
I am writing a script that will take a number of optional parameters including positive and negative numbers. I have used getopts before for parsing a parameter list, but it doesn't seem to be able to handle numbers (especially negative numbers) as parameters.
Like this:
script -5 (will display the last 5 lines of the log)
script 5 (will display all entries that have happened in the last 5 days)
script -5 -f FileName (will display the last 5 lines using the input file of FileName)
When I use getopts it doesn't like the -5 (Invalid parameter). I would like to make the script robust enough to handle this:
script -f filename -5
but I don't think that is possible with getopts.
I'm using AIX and ksh - if that helps.
Einstein47
("The only reason I would take up exercise would be so I could hear heavy breathing again."
Like this:
script -5 (will display the last 5 lines of the log)
script 5 (will display all entries that have happened in the last 5 days)
script -5 -f FileName (will display the last 5 lines using the input file of FileName)
When I use getopts it doesn't like the -5 (Invalid parameter). I would like to make the script robust enough to handle this:
script -f filename -5
but I don't think that is possible with getopts.
I'm using AIX and ksh - if that helps.
Einstein47
("The only reason I would take up exercise would be so I could hear heavy breathing again."