Sponsored Content
Top Forums UNIX for Dummies Questions & Answers anchoring regex using case and ksh Post 302220367 by popeye on Thursday 31st of July 2008 01:07:17 PM
Old 07-31-2008
Instead of doing all the greps, Id rather read through the file. I dont want to use ifs, I want to use case. Ifs are shown for a psuedo code explaination.

while read ip model ios hostname
do
case $ios in

if $ios is 11.0 print I have 11.0
if $ios is 12.0 mainline print I have 12.0
if $ios is 12.0 not mainline print I have 12.0 T or above
if $ios is single digit followed by a single digit it must be an os print I have an os

esac
done < seedfile
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Case (ksh)

Isn't any "NOT" operator that can be used in the case construction like : case $VAR (NOT) in option1 | option2 | option 3...) COMMAND ;; esac Or something similiar to the "default" from switch, so I could at least do something like this: case $VAR in ... (2 Replies)
Discussion started by: 435 Gavea
2 Replies

2. Shell Programming and Scripting

ksh case problem

I'm trying to run a ksh script with a case condition to handle parameters. #!/bin/ksh db_start(){ *code } db_shut(){ *code } case "$1" in up) db_start TRNG ;; down) db_shut TRNG ;; *) echo "Usage: $0 { up | down }" (3 Replies)
Discussion started by: digiteck
3 Replies

3. Shell Programming and Scripting

How to specify 'not case sensitive' in regex (nawk, sed, patern expencions)?

Is it possible to make the search in regular exprecion or in matching parts of sed, nawk and others to IGNORE the case of the search string? I mean, like if used 'grep' with -i option: > grep -i "abc" file I would like to be able to do the same, say, by nawk: > nawk '/abc/ {print $0}'... (4 Replies)
Discussion started by: alex_5161
4 Replies

4. Shell Programming and Scripting

ksh case statement

I am trying to write a ksh script using the case statement to select certain directories to remove. The directories that I am looking for are in the following format 2008-10-10. I want to exclude all other files/directories that contain anything other the 4 digit year,a dash, 2 digit month, a... (2 Replies)
Discussion started by: dgilc
2 Replies

5. UNIX for Dummies Questions & Answers

ksh case structure

Hello Experts, I ve been trying to build another shell where I am using the following code. transact="tv5cpc1" case "$transact" in "...cp..") xActType="" ;; "...de..") xActType="sp_dep" ;; "...ep..") xActType="sp_epa" ;; "....v.") ... (4 Replies)
Discussion started by: hkansal
4 Replies

6. Shell Programming and Scripting

bash regex =~ case insensetive, possible?

It can get very annoying that bash regex =~ is case-sensetive, is there a way to set it to be case-insensetive? if ]; then echo match else echo no match fi (8 Replies)
Discussion started by: TehOne
8 Replies

7. Shell Programming and Scripting

[BASH] recognise new line regex in case statement

Hi, I'm trying to write a routine to parse a file that contains data that will be read into arrays. The file is composed of labels to identify data types and arbitrary lines of data with the usual remarks and empty new lines as is common with config files. The initial pass is built as so:... (3 Replies)
Discussion started by: ASGR
3 Replies

8. Shell Programming and Scripting

lower to upper case in ksh

What is the command to change the contents of a file to UPPER case. Here in this file below you see some characters are Sp, Ch 1200812270046581 22885072800000652 B86860003OLFXXX592123320081227 22885029800000652 B86860003ODL-Sp592123420081227 22885093700000652-B94030001ODL-Ch592123520081227... (4 Replies)
Discussion started by: kshuser
4 Replies

9. Shell Programming and Scripting

Using an array with a case statement in KSH

Hi, I'm really new ro shell scripting (actually any kind of programming) and am pretty sure I'm making a pretty basic error here but I can't for the life of me figure it out. What I'm trying to do is get an array working with a case statement in a KSH script. The code is as follows: ... (3 Replies)
Discussion started by: SReilly
3 Replies

10. Shell Programming and Scripting

Question about REGEX Patterns and Case Sensitivity?

Hello All, I'm in the middle of a script and I'm doing some checks with REGEX (i.e. using the '"shopt -s nocasematch" that at least the first one should print "FALSE" but it prints "TRUE"..? For Example: #!/bin/bash MY_VAR="HELLO" ### This prints "TRUE" PATTERN_1="^*" if ] then... (5 Replies)
Discussion started by: mrm5102
5 Replies
Devel::Symdump(3pm)					User Contributed Perl Documentation				       Devel::Symdump(3pm)

NAME
Devel::Symdump - dump symbol names or the symbol table SYNOPSIS
# Constructor require Devel::Symdump; @packs = qw(some_package another_package); $obj = Devel::Symdump->new(@packs); # no recursion $obj = Devel::Symdump->rnew(@packs); # with recursion # Methods @array = $obj->packages; @array = $obj->scalars; @array = $obj->arrays; @array = $obj->hashes; @array = $obj->functions; @array = $obj->filehandles; # deprecated, use ios instead @array = $obj->dirhandles; # deprecated, use ios instead @array = $obj->ios; @array = $obj->unknowns; # only perl version < 5.003 had some $string = $obj->as_string; $string = $obj->as_HTML; $string = $obj1->diff($obj2); $string = Devel::Symdump->isa_tree; # or $obj->isa_tree $string = Devel::Symdump->inh_tree; # or $obj->inh_tree # Methods with autogenerated objects # all of those call new(@packs) internally @array = Devel::Symdump->packages(@packs); @array = Devel::Symdump->scalars(@packs); @array = Devel::Symdump->arrays(@packs); @array = Devel::Symdump->hashes(@packs); @array = Devel::Symdump->functions(@packs); @array = Devel::Symdump->ios(@packs); @array = Devel::Symdump->unknowns(@packs); DESCRIPTION
This little package serves to access the symbol table of perl. "Devel::Symdump->rnew(@packages)" returns a symbol table object for all subtrees below @packages. Nested Modules are analyzed recursively. If no package is given as argument, it defaults to "main". That means to get the whole symbol table, just do a "rnew" without arguments. The global variable $Devel::Symdump::MAX_RECURSION limits the recursion to prevent contention. The default value is set to 97, just low enough to survive the test suite without a warning about deep recursion. "Devel::Symdump->new(@packages)" does not go into recursion and only analyzes the packages that are given as arguments. packages, scalars, arrays, hashes, functions, ios The methods packages(), scalars(), arrays(), hashes(), functions(), ios(), and (for older perls) unknowns() each return an array of fully qualified symbols of the specified type in all packages that are held within a Devel::Symdump object, but without the leading "$", "@" or "%". In a scalar context, they will return the number of such symbols. Unknown symbols are usually either formats or variables that haven't yet got a defined value. as_string as_HTML As_string() and as_HTML() return a simple string/HTML representations of the object. diff Diff() prints the difference between two Devel::Symdump objects in human readable form. The format is similar to the one used by the as_string method. isa_tree inh_tree Isa_tree() and inh_tree() both return a simple string representation of the current inheritance tree. The difference between the two methods is the direction from which the tree is viewed: top-down or bottom-up. As I'm sure, many users will have different expectation about what is top and what is bottom, I'll provide an example what happens when the Socket module is loaded: % print Devel::Symdump->inh_tree AutoLoader DynaLoader Socket DynaLoader Socket Exporter Carp Config Socket The inh_tree method shows on the left hand side a package name and indented to the right the packages that use the former. % print Devel::Symdump->isa_tree Carp Exporter Config Exporter DynaLoader AutoLoader Socket Exporter DynaLoader AutoLoader The isa_tree method displays from left to right ISA relationships, so Socket IS A DynaLoader and DynaLoader IS A AutoLoader. (Actually, they were at the time this manpage was written) You may call both methods, isa_tree() and inh_tree(), with an object. If you do that, the object will store the output and retrieve it when you call the same method again later. The typical usage would be to use them as class methods directly though. SUBCLASSING
The design of this package is intentionally primitive and allows it to be subclassed easily. An example of a (maybe) useful subclass is Devel::Symdump::Export, a package which exports all methods of the Devel::Symdump package and turns them into functions. AUTHORS
Andreas Koenig <andk@cpan.org> and Tom Christiansen <tchrist@perl.com>. Based on the old dumpvar.pl by Larry Wall. COPYRIGHT, LICENSE This module is Copyright (c) 1995, 1997, 2000, 2002, 2005, 2006 Andreas Koenig "<andk@cpan.org>". All rights reserved. This library is free software; you may use, redistribute and/or modify it under the same terms as Perl itself. perl v5.10.1 2008-04-01 Devel::Symdump(3pm)
All times are GMT -4. The time now is 03:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy