How to declare the two argument for optional switch ?
I have a script that search for a string in current or old zipped log file.
Im using a option something like this
Since $1 can have only one argument should be passed when user select swicth -c and -o need to have mandatory two arguments YYYY-mm-dd & OLD_FILE_NAME in case of -o switch.
Can we have this method ?? please suggest. Thanks in advance
Hi Unix Gurus,
i am on learning path of unix, and yet to discover many things. I came across with this requirement where i need to pass parameters but the position of parameters is not fixed so after doing some google search got to know "getopts" can handle that. So here is my code:
function... (3 Replies)
Please forgive but I am new to Linux and still learning. When installing Linux (any flavor) over PXE, it asks if you want to customize which packages to install. Most engineers ask us to install all packages but this entails A LOT of clicking. Is there a way to "select all" packages by using a... (3 Replies)
Hi
Am pretty new to C..
Am trying to pass the arguments from command line and use them in switch case statement..
i have tried the following
#include <stdlib.h>
main(int argc, char* argv)
{
int num=0;
if ( argc == 2 )
num = argv;
printf("%d is the num value",num);
switch ( num )
... (2 Replies)
Here is my script:
#!/bin/ksh
usage ()
{
echo " Usage: $0 <opt1> <opt2> <opt3> <opt4>"
}
if ; then
usage
exit;
fi
prog -a $1 -b $2 -c $3 -d $4 2>&1 | tee -a ~/$1.log
I want argument 4 to be optional, so if there's no argument for opt4, that it doesn't... (8 Replies)
I have an awk script which can be used in the following ways:
xi and xf will only be mandatory when processing the file fin.zc.
awk -v xi=0/-0.5 -v xf=80/30 -f ./zc2cmd.awk fin.zc > fout.cmod
awk -f ./zc2cmd.awk -u
awk -f ./zc2cmd.awk --usg
awk -f ./zc2cmd.awk -e
awk -f ./zc2cmd.awk... (1 Reply)
I have a switch statement, and I want to have two options performing the same thing. For example, if $opt matches "-fb" or "--fbase", I want to perform the same operation. How can I include various matches in "case" ?
switch ($opt)
case "-T":
set Atpath = $par
set opt_tpath =... (8 Replies)
Hello,
I have a shell script "Test.ksh" and I need to pass 8 parameters/arguments while executing the script
./Test.ksh 1 2 3 4 5 6 7 8
Out of these I want first 3 to be compulsory and rest 5 to be optional. Can you suggest the way to do this like and also how to pass these optional... (3 Replies)
field 12345 12345
field 12345
field 12345 123456
last fleld (from three) is optional, but if it occures It has to be composed only of nummbers and maximum 5 positions long.
If I use:
grep "^field \{5\}"
I get:
field 12345 12345
field 12345
field 12345 123456
But I wont... (11 Replies)
Hi,
I am trying to call a function inside a shell script. Is there a way in which I can make the parameters options in the call?
Please help me with this.
Thanks!!! (2 Replies)