Sponsored Content
Top Forums Shell Programming and Scripting Using default value with getopts and case Post 302589438 by its on Wednesday 11th of January 2012 06:34:08 PM
Old 01-11-2012
Question Using default value with getopts and case

Hey Guys

I have a program in shell which is reading default values from a file

filename: default
Code:
MAN=Value1
MANPD=997
REPPD=P1G6

Now the code calling is

Code:
#!/bin/sh

. /home/default

while getopts t:D: name
do
 case $name in
  t) TYPE=$OPTARG;;
  D) PDN=${OPTARG:=$MAN};;
esac
done

echo $TYPE
echo $PDN

echo $MAN

So basically if any value to -D is given PDN gets that, else it gets the value of MAN.. now $MAN is giving an output but $PDN (when not set @ runtime) is not setting itself to $MAN..

What am I doing wrong??
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

lower case to upper case string conversion in shell script

How can convert a Lower case variable value to an upper case in the kron shell script. (3 Replies)
Discussion started by: dchalavadi
3 Replies

2. Shell Programming and Scripting

Script needed to select and delete lower case and mixed case records

HELLO ALL, URGENTLY NEEDED A SCRIPT TO SELECT AND DELETE LOWER AND MIXED CASE RECORDS FROM A COLUMN IN A TABLE. FOR EXAMPLE : Table name is EMPLOYEE and the column name is CITY and the CITY column records will be: Newyork washington ... (1 Reply)
Discussion started by: abhilash mn
1 Replies

3. Shell Programming and Scripting

getopts case statement failure

Hi, I have a getopts that works fine if I provide an option but I want it to exit if nothing is given, but for some reason it drops out and continues with the script. Any ideas? while getopts d:m:y: o do case $o in d) day=$OPTARG ;; ... (1 Reply)
Discussion started by: nhatch
1 Replies

4. Shell Programming and Scripting

data array needs to change upper case to lower case

Hi all, i have a data array as followes. ARRAY=DFSG345GGG ARRAY=234FDFG090 ARRAY=VDFVGBGHH so on.......... i need all english letters to be change to lower case. So i am expecting to see ARRAY=dfsg345ggg ARRAY=234fdfg090 ARRAY=vdfvgbghh so on........ If i have to copy this data in... (8 Replies)
Discussion started by: usustarr
8 Replies

5. Shell Programming and Scripting

How to execute default in getopts when no option is given ?

hi, here is a ksh script i wrote using getopts... i want to find out how i can run it in default mode when no option is mentioned and no arguments are provided... ? i.e if the script name is final1, then just running final1 should run in default mode.... while getopts 1:2:3:4: mode ... (1 Reply)
Discussion started by: pravsripad
1 Replies

6. Shell Programming and Scripting

sed ignoring case for search but respecting case for subtitute

Hi I want to make string substitution ignoring case for search but respecting case for subtitute. Ex changing all occurences of "original" in a file to "substitute": original becomes substitute Origninal becomes Substitute ORIGINAL becomes SUBSTITUTE I know this a little special but it's not... (1 Reply)
Discussion started by: kmchen
1 Replies

7. Shell Programming and Scripting

Conversion from Upper Case to Lower Case Condition based

Hello Unix Gurus : It would be really appreciative if can find a solution for this . I have records in a file . I need to Capitalize the records based on condition . For Example i tried the following Command COMMAND --> fgrep "2000YUYU" /export/home/oracle/TST/data.dat | tr '' ''... (12 Replies)
Discussion started by: tsbiju
12 Replies

8. Shell Programming and Scripting

Change first letter of a word from lower case to upper case

Hi all, I am trying to find a way to change first letter in a word from lower case to upper case. It should be done for each first word in text or in paragraph, and also for each word after punctuation like . ; : ! ?I found the following command sed -i 's/\s*./\U&\E/g' $@ filenamebut... (7 Replies)
Discussion started by: georgi58
7 Replies

9. Shell Programming and Scripting

ksh - default value for getopts option's argument

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
MAN.CONF(5)                                                     File Formats Manual                                                    MAN.CONF(5)

NAME
man.conf - configuration file for man DESCRIPTION
This is the configuration file for the man(1), apropos(1), and makewhatis(8) utilities. Its presence, and all directives, are optional. This file is an ASCII text file. Leading whitespace on lines, lines starting with '#', and blank lines are ignored. Words are separated by whitespace. The first word on each line is the name of a configuration directive. The following directives are supported: manpath path Override the default search path for man(1), apropos(1), and makewhatis(8). It can be used multiple times to specify multiple paths, with the order determining the manual page search order. Each path is a tree containing subdirectories whose names consist of the strings 'man' and/or 'cat' followed by the names of sections, usually single digits. The former are supposed to contain unformatted manual pages in mdoc(7) and/or man(7) format; file names should end with the name of the section preceded by a dot. The latter should contain preformatted manual pages; file names should end with '.0'. Creating a mandoc.db(5) database with makewhatis(8) in each directory configured with manpath is recommended and necessary for apropos(1) to work, but not strictly required for man(1). output option [value] Configure the default value of an output option. These directives are overridden by the -O command line options of the same names. For details, see the mandoc(1) manual. option value used by -T fragment none html includes string html indent integer ascii, utf8 man string html paper string ps, pdf style string html width integer ascii, utf8 _whatdb path/whatis.db This directive provides the same functionality as manpath, but using a historic and misleading syntax. It is kept for backward compatibility for now, but will eventually be removed. FILES
/etc/man.conf EXAMPLES
The following configuration file reproduces the defaults: installing it is equivalent to not having a man.conf file at all. manpath /usr/share/man manpath /usr/X11R6/man manpath /usr/local/man SEE ALSO
apropos(1), man(1), makewhatis(8) HISTORY
A relatively complicated man.conf file format first appeared in 4.3BSD-Reno. For OpenBSD 5.8, it was redesigned from scratch, aiming for simplicity. AUTHORS
Ingo Schwarze <schwarze@openbsd.org> Debian December 28, 2016 MAN.CONF(5)
All times are GMT -4. The time now is 11:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy