Sponsored Content
Full Discussion: Using arrays in shell
Top Forums Shell Programming and Scripting Using arrays in shell Post 302366481 by cfajohnson on Thursday 29th of October 2009 03:22:56 PM
Old 10-29-2009

You must be using ksh88 or pdksh. Try this:

Code:
for element in "${MASTERARRAY[@]}"
do
  case $element in END_OF_ARRAY) break;; esac
  eval "set -- \"\${${element%_*}[@]}\" "
  for e
  do
      case $e in END_OF_ARRAY) break;; esac
      printf "\nArray: %s\n" "$e"
  done
done

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bourne Shell and Arrays

Hi everyone, first post here so please be gentle :-) I normally likle to script in Bourne Shell simply for guarenteed compatibility across any system I might run across but this latest problem has me stumped. Arrays is a rather significant construct missing from sh and after finding a way to... (2 Replies)
Discussion started by: Unbeliever
2 Replies

2. Shell Programming and Scripting

arrays in shell script

Hi, can we use arrays in shell script? I have this so far: #!/bin/sh isql -Usa -P -S DBSERVER -o output << EOF sp_transactions "state", "prepared", "xactname" go / EOF the file 'output'' will be have many entries and I want to caputre the transaction names only: grep 000 output works... (3 Replies)
Discussion started by: melanie_pfefer
3 Replies

3. Shell Programming and Scripting

how to use arrays in c shell

hi :) i need help to explain arrays 2D in c shell like this in c++ int a (6 Replies)
Discussion started by: hgphsf
6 Replies

4. Shell Programming and Scripting

shell / awk arrays

I have a bash shell script that sources a data file, the data file has array values such as: #--data file ---# sg_name="db1" sg_size="12892" sg_allow="50000" sg_name="db2" sg_size="12892" sg_allow="50000" export sg_name sg_size sg_allow #--end data file --# In my shell script... (8 Replies)
Discussion started by: lochraven
8 Replies

5. Shell Programming and Scripting

C shell arrays

how do you declare an array in the C shell and loop through each element? (2 Replies)
Discussion started by: npatwardhan
2 Replies

6. Shell Programming and Scripting

I need help with arrays in C Shell

Hi guys could you please post links that explain how to use and manipulate arrays in c shell (.csh files) ? examples are useful too :rolleyes: (5 Replies)
Discussion started by: domain
5 Replies

7. Shell Programming and Scripting

arrays in C shell

hi guys, i have the following code in C shell.. set i=0 while ($i < 11) master_array=${ARRAY} i++ done it gives me error at line 3: Variable syntax. what is wrong here? any help is appreciated. (4 Replies)
Discussion started by: npatwardhan
4 Replies

8. Shell Programming and Scripting

Shell script for 2 arrays

I have 2 arrays abc and xyz abc = ( a b c d e f g h i j k l m n o p q r s t u v w x y z ) and xyz = ( b c d e f ) lets assume a .... z are the file name. I have to perform a pattern replacement on each file present in abc array accept the files i have in xyz array. and i am doing... (4 Replies)
Discussion started by: kukretiabhi13
4 Replies

9. Shell Programming and Scripting

Shell arrays need help

Ok so spaces separate elements. What if you wanted an element to have a space in it? For instance: nums="one two three and a half" where "three and a half" is THE SAME element? (3 Replies)
Discussion started by: stevenswj
3 Replies

10. Shell Programming and Scripting

Arrays in Shell Scripts

I have defined an array like this: set -A MYARRAY MYARRAY=file1 MYARRAY=file2 MYARRAY=file3 MYARRAY=file4 i=0 while } ]] do echo "File Name $i :" ${MYARRAY} i=`expr $i + 1 ` echo "value of i=" $i done This works perfectly and shows... (4 Replies)
Discussion started by: Hangman2
4 Replies
Reindent(3pm)						User Contributed Perl Documentation					     Reindent(3pm)

NAME
XML::Filter::Reindent - Reformats whitespace for pretty printing XML SYNOPSIS
use XML::Handler::Composer; use XML::Filter::Reindent; my $composer = new XML::Handler::Composer (%OPTIONS); my $indent = new XML::Filter::Reindent (Handler => $composer, %OPTIONS); DESCRIPTION
XML::Filter::Reindent is a sub class of XML::Filter::DetectWS. XML::Filter::Reindent can be used as a PerlSAX filter to reformat an XML document before sending it to a PerlSAX handler that prints it (like XML::Handler::Composer.) Like XML::Filter::DetectWS, it detects ignorable whitespace and blocks of whitespace characters in certain places. It uses this information and information supplied by the user to determine where whitespace may be modified, deleted or inserted. Based on the indent settings, it then modifies, inserts and deletes characters and ignorable_whitespace events accordingly. This is just a first stab at the implementation. It may be buggy and may change completely! Constructor Options o Handler The PerlSAX handler (or filter) that will receive the PerlSAX events from this filter. o Tab (Default: one space) The number of spaces per indent level for elements etc. in document content. o Newline (Default: "x0A") The newline to use when re-indenting. The default is the internal newline used by XML::Parser, XML::DOM etc., and should be fine when used in combination with XML::Handler::Composer. $self->indent_children ($start_element_event) This method determines whether children of a certain element may be reformatted. The default implementation checks the PreserveWS parameter of the specified start_element event and returns 0 if it is set or MAYBE otherwise. The value MAYBE(2) indicates that further investigation is needed, e.g. by examining the element contents. A value of 1 means yes, indent the child nodes, no further investigation is needed. NOTE: the PreserveWS parameter is set by the parent class, XML::Filter::DetectWS, when the element or one of its ancestors has the attribute xml:space="preserve". Override this method to tweak the behavior of this class. $self->indent_element ($start_element_event, $parent_says_indent) This method determines whether a certain element may be re-indented. The default implementation returns the value of the $parent_says_indent parameter, which was set to the value returned by indent_children for the parent element. In other words, the element will be re-indented if the parent element allows it. Override this method to tweak the behavior of this class. I'm not sure how useful this hook is. Please provide feedback! Current Implementation The current implementation puts all incoming Perl SAX events in a queue for further processing. When determining which nodes should be re- indented, it sometimes needs information from previous events, hence the use of the queue. The parameter (Compress => 1) is added to matching start_element and end_element events with no events in between This indicates to an XML printer that a compressed notation can be used, e.g <foo/>. If an element allows reformatting of its contents (xml:space="preserve" was not active and indent_children returned MAYBE), the element contents will be reformatted unless it only has one child node and that child is a regular text node (characters event.) In that case, the element will be printed as <foo>text contents</foo>. If you want element nodes with just one text child to be reindented as well, simply override indent_children to return 1 instead of MAYBE (2.) This behavior may be changed or extended in the future. CAVEATS
This code is highly experimental! It has not been tested well and the API may change. The code that detects blocks of whitespace at potential indent positions may need some work. AUTHOR
Original Author is Enno Derksen. Send bug reports, hints, tips, suggestions to T.J. Mather at <tjmather@tjmather.com>. perl v5.10.1 2002-04-06 Reindent(3pm)
All times are GMT -4. The time now is 10:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy