Hi All,
I'm trying to test a Hash variable but it's not working. Here is my code - can anyone tell me if the test is valid?
for (keys %enabled_yn) {
if ($enabled_yn{$1} =~ m/\s+Y/) {
$html =~ s/%(\w+)%/\<b\>\<font color\=orange\>$enabled_yn{$1}\<\/font\>\<\/b\>/g;
}... (1 Reply)
hi i am trying to get digits inside brackes from file , whose structure is defined below
CREATE TABLE TELM
(SOC_NO CHAR (3) NOT NULL,
TXN_AMOUNT NUMBER (17,3)
SIGN_ON_TIME CHAR (8)
TELLER_APP_LIMIT NUMBER (17,3)
FIL01 ... (2 Replies)
Hi all,
I want to search for a data type in a line.For this in a loop i am checking for $DATA_TYPE in a line using grep.But grep is not able to find when i give this.
Can any one tell me how to check string in $DATA_TYPE variable in line usign grep (or) any other way to do the above task.
... (4 Replies)
Hey there,
I have a table of contents file of the form
1 Title1
1.1 Subtitle1
1.1.1 Subsubtitle1
1.1.2 Subsubtitle2
...
and want to count the number of dots in the first field to find out the level of the section.
I use the gsub function for the job, which works if I pass the pattern... (2 Replies)
Hallo!
Example.
#!/bin/bash
BACKUP_DIR=/home/userx/backups/evolution
echo $BACKUP_DIR
# delete the first character from the string
BACKUP_DIR=$(echo $BACKUP_DIR | cut -c 2-)
echo $BACKUP_DIR
It works. It does want I want, delete the first character from string in the... (11 Replies)
I have a 2 files in .gz format and it consists of 5 million lines the format of the file would be
gzcat file1.gz | more
abcde
aerere
ffgh56
..
..
12345
gzcat file2.gz | more
abcde , 12345 , 67890,
ffgh56 , 45623 ,12334
whatever the string is in the file1 should be matched... (3 Replies)
hi,
i have a variable which contains some file names delimited by a single space.
FNAME="s1.txt s2.lst s3.cvs s4.lst"
i have another variable that contains a pattern
FILE_PATTERN="*.lst"
i want to take the filenames from FNAME variable and assign each file name in to an array say
for... (8 Replies)
The sample file:
dept1: user1,user2,user3
dept2: user4,user5,user6
dept3: user7,user8,user9
I want to match by '/^dept2.*/' but don't want to have substring 'dept2:' in output. How to compose such regex? (8 Replies)
The bash bash below extracts the oldest folder from a directory and stores it in filename
That result will match a line in bold in input. In the matching line there is an_xxx digit in italics that
(once the leading zero is removed) will match a line in link. That is the lint to print in output.... (2 Replies)
For example: I am grepping "Hello" from a file and there are 10 matches. So all ten lines with match will get stored into a variable($match). Now I want to ignore those lines which have "Hi" present in that.
Currently I tried this: match = grep "Hello" file | grep -v "Hi" file
But that's not... (2 Replies)
Discussion started by: pavan
2 Replies
LEARN ABOUT SUNOS
getopt
getopt(1) User Commands getopt(1)NAME
getopt - parse command options
SYNOPSIS
set -- ` getopt optstring $ * `
DESCRIPTION
The getopts command supersedes getopt. For more information, see NOTES below.
getopt is used to break up options in command lines for easy parsing by shell procedures and to check for legal options. optstring is a
string of recognized option letters; see getopt(3C). If a letter is followed by a colon (:), the option is expected to have an argument
which may or may not be separated from it by white space. The special option - is used to delimit the end of the options. If it is used
explicitly, getopt recognizes it; otherwise, getopt generates it; in either case, getopt places it at the end of the options. The posi-
tional parameters ($1 $2 ...) of the shell are reset so that each option is preceded by a - and is in its own positional parameter; each
option argument is also parsed into its own positional parameter.
EXAMPLES
Example 1: Processing the arguments for a command
The following code fragment shows how one might process the arguments for a command that can take the options -a or -b, as well as the
option -o, which requires an argument:
set -- `getopt abo: $*`
if [ $? != 0 ]
then
echo $USAGE
exit 2
fi
for i in $*
do
case $i in
-a | -b) FLAG=$i; shift;;
-o) OARG=$2; shift 2;;
--) shift; break;;
esac
done
This code accepts any of the following as equivalent:
cmd -aoarg filename1 filename2
cmd -a -o arg filename1 filename2
cmd -oarg -a filename1 filename2
cmd -a -oarg -- filename1 filename2
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
|CSI |enabled |
+-----------------------------+-----------------------------+
SEE ALSO intro(1), getopts(1), getoptcvt(1), sh(1), shell_builtins(1), getopt(3C), attributes(5)DIAGNOSTICS
getopt prints an error message on the standard error when it encounters an option letter not included in optstring.
NOTES
getopt will not be supported in the next major release. For this release a conversion tool has been provided, namely, getoptcvt. For more
information, see getopts(1) and getoptcvt(1).
Reset optind to 1 when rescanning the options.
getopt does not support the part of Rule 8 of the command syntax standard (see intro(1)) that permits groups of option-arguments following
an option to be separated by white space and quoted. For example,
cmd -a -b -o "xxx z yy" filename
is not handled correctly. To correct this deficiency, use the getopts command in place of getopt.
If an option that takes an option-argument is followed by a value that is the same as one of the options listed in optstring (referring to
the earlier EXAMPLES section, but using the following command line:
cmd -o -a filename
getopt always treats it as an option-argument to -o; it never recognizes -a as an option. For this case, the for loop in the example shifts
past the filename argument.
SunOS 5.10 7 Jan 2000 getopt(1)