Sponsored Content
Top Forums Shell Programming and Scripting Using default value with getopts and case Post 302589447 by Chubler_XL on Wednesday 11th of January 2012 07:53:03 PM
Old 01-11-2012
getopts dosn't support optional : arguments so you will need to quote a blank value eg:

Code:
$ yourscript -D "" -t mytype
mytype
Value1
Value1

Or not pass -D at all, and assign PDN=$MAN before calling getops

Last edited by Chubler_XL; 01-11-2012 at 08:58 PM..
This User Gave Thanks to Chubler_XL For This Post:
 

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
Prima::IniFile(3)					User Contributed Perl Documentation					 Prima::IniFile(3)

NAME
Prima::IniFile - support of Windows-like initialization files DESCRIPTION
The module contains a class, that provides mapping of text initialization file to a two-level hash structure. The first level is called sections, which groups the second level hashes, called items. Sections must have unique keys. The items hashes values are arrays of text strings. The methods, operated on these arrays are get_values, set_values, add_values and replace_values. SYNOPSIS
use Prima::IniFile; my $ini = create Prima::IniFile; my $ini = create Prima::IniFile FILENAME; my $ini = create Prima::IniFile FILENAME, default => HASHREF_OR_ARRAYREF; my $ini = create Prima::IniFile file => FILENAME, default => HASHREF_OR_ARRAYREF; my @sections = $ini->sections; my @items = $ini->items(SECTION); my @items = $ini->items(SECTION, 1); my @items = $ini->items(SECTION, all => 1); my $value = $ini-> get_values(SECTION, ITEM); my @vals = $ini-> get_values(SECTION, ITEM); my $nvals = $ini-> nvalues(SECTION, ITEM); $ini-> set_values(SECTION, ITEM, LIST); $ini-> add_values(SECTION, ITEM, LIST); $ini-> replace_values(SECTION, ITEM, LIST); $ini-> write; $ini-> clean; $ini-> read( FILENAME); $ini-> read( FILENAME, default => HASHREF_OR_ARRAYREF); my $sec = $ini->section(SECTION); $sec->{ITEM} = VALUE; my $val = $sec->{ITEM}; delete $sec->{ITEM}; my %everything = %$sec; %$sec = (); for ( keys %$sec) { ... } while ( my ($k,$v) = each %$sec) { ... } METHODS
add_values SECTION, ITEM, @LIST Adds LIST of string values to the ITEM in SECTION. clean Cleans all internal data in the object, including the name of the file. create PROFILE Creates an instance of the class. The PROFILE is treated partly as an array, partly as a hash. If PROFILE consists of a single item, the item is treated as a filename. Otherwise, PROFILE is treated as a hash, where the following keys are allowed: file FILENAME Selects name of file. default %VALUES Selects the initial values for the file, where VALUES is a two-level hash of sections and items. It is passed to read, where it is merged with the file data. get_values SECTION, ITEM Returns array of values for ITEM in SECTION. If called in scalar context, and there is more than one value, the first value in list is returned. items SECTION [ HINTS ] Returns items in SECTION. HINTS parameters is used to tell if a multiple-valued item must be returned as several items of the same name; HINTS can be supplied in the following forms: items( $section, 1 ) items( $section, all => 1); new PROFILE Same as create. nvalues SECTION, ITEM Returns number of values in ITEM in SECTION. read FILENAME, %PROFILE Flushes the old content and opens new file. FILENAME is a text string, PROFILE is a two-level hash of default values for the new file. PROFILE is merged with the data from file, and the latter keep the precedence. Does not return any success values but, warns if any error is occurred. replace_values SECTION, ITEM, @VALUES Removes all values form ITEM in SECTION and assigns it to the new list of VALUES. section SECTION Returns a tied hash for SECTION. All its read and write operations are reflected in the caller object, which allows the following syntax: my $section = $inifile-> section( 'Sample section'); $section-> {Item1} = 'Value1'; which is identical to $inifile-> set_items( 'Sample section', 'Item1', 'Value1'); sections Returns array of section names. set_values SECTION, ITEM, @VALUES Assigns VALUES to ITEM in SECTION. If number of new values are equal or greater than the number of the old, the method is same as replace_values. Otherwise, the values with indices higher than the number of new values are not touched. write Rewrites the file with the object content. The object keeps an internal modification flag under name "{changed}"; in case it is "undef", no actual write is performed. AUTHORS
Anton Berezin, <tobez@plab.ku.dk> Dmitry Karasik <dmitry@karasik.eu.org> perl v5.14.2 2009-02-24 Prima::IniFile(3)
All times are GMT -4. The time now is 03:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy