10 More Discussions You Might Find Interesting
1. UNIX for Beginners Questions & Answers
There are many places where I can see the syntax description for optargs, which, usually boils down to this:
getopts OPTSTRING VARNAME
where:
OPTSTRING tells getopts which options to expect and where to expect arguments
VARNAME tells getopts which shell-variable to use for option reporting... (2 Replies)
Discussion started by: sharkura
2 Replies
2. Shell Programming and Scripting
Hello everyone,
I need help in understanding the default value for getopts option's argument in ksh. I've written a short test script:
#!/bin/ksh
usage(){
printf "Usage: -v and -m are mandatory\n\n"
}
while getopts ":v#m:" opt; do
case $opt in
v) version="$OPTARG";;
... (1 Reply)
Discussion started by: da1
1 Replies
3. Shell Programming and Scripting
I'm trying to crudely hack my way through some data processing.
I have file.txt with around 17,000 lines like this:
ACYPI002690-PA.aa.afa.afa.trim_phyml_tree_fullnames_fullhomolog.txt 3 72 71
ACYPI002690-PA.aa.afa.afa.trim_phyml_tree_fullnames_fullhomolog.txt 97 111 71... (1 Reply)
Discussion started by: pathunkathunk
1 Replies
4. Shell Programming and Scripting
EDIT: -- SOLVED --
Heyas,
Getting used to optargs, but by far not understanding it.
So i have that script that shall be 'changeable', trying to use the passed arguments to modify the script visuals.
Passing:
browser -t test -d sect $HOME
Where -t should change the title,
and -d... (0 Replies)
Discussion started by: sea
0 Replies
5. Shell Programming and Scripting
Hi I have below code in one of my shell script:
if ; then fail $USAGE; fi
while getopts hz:r:t:dz: o
do
case "$o" in
h) echo $USAGE ; exit 0;;
r) export REQ_ID="$OPTARG";;
t) TIMESPAN="$OPTARG";;
d) detail="true";;
) ... (0 Replies)
Discussion started by: mohsin.quazi
0 Replies
6. Shell Programming and Scripting
Hi Gurus
I am trying to figure out (with not much success) how to pass two values to a single getopts argument ... for example
./script -a Tuesday sausagesThe $OPTARG variable seems to only get populated with the first argument. What im looking to do is to process the first argument (i.e.make... (6 Replies)
Discussion started by: rethink
6 Replies
7. Shell Programming and Scripting
Hi there, if i have a simple getopts like below ...how can i make it so that if somebody enters more than one -g argument for example, it will error with a " you cannot enter more than one -g" or something like that.?
I want to only allow one instance of a -g or a -h etc ..
while getopts... (1 Reply)
Discussion started by: hcclnoodles
1 Replies
8. Shell Programming and Scripting
Hi,
I'm using bash and ksh93 compatible derivatives.
In a recent getopts experience, I found myself spending far too much
time on this little problem. I hope someone can help...
So here's the deal.
I want to build have a command line interface that accepts either zero,
one, or... (4 Replies)
Discussion started by: duderonomy
4 Replies
9. Shell Programming and Scripting
Hi all,
I am parsing command line options using getopts.
The problem is that mandatory argument options following ":" is taking next option as argument if it is not followed by any argument.
Below is the script:
while getopts :hd:t:s:l:p:f: opt
do
case "$opt" in
-h|-\?)... (2 Replies)
Discussion started by: gurukottur
2 Replies
10. Shell Programming and Scripting
I want to write a script which will check the arguments and if there is a single space(if 2 more more space in a row , then do not touch), replace it with _ and then gather the argument
so, program will be ran
./programname hi hello hi usa now hello hello
so, inside of program,... (7 Replies)
Discussion started by: convenientstore
7 Replies