The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Need Help with awk and arrays fusionX Shell Programming and Scripting 7 02-11-2008 06:41 PM
arrays in shell script melanie_pfefer Shell Programming and Scripting 3 05-18-2007 09:36 AM
Script to Monitor databases help with arrays nelmest Shell Programming and Scripting 1 09-05-2005 11:50 PM
KSH and arrays whited05 Shell Programming and Scripting 1 06-24-2005 01:07 PM
CGI passing arrays/hashes to another CGI script WIntellect Shell Programming and Scripting 2 01-13-2003 11:22 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 06-22-2005
sidamin810 sidamin810 is offline
Registered User
  
 

Join Date: Jun 2005
Location: Mississauga
Posts: 12
ksh script - arrays

hello all.. I have been browsing / searching through the forum and have yet not been able to find what I was looking for.

I am fairly new to ksh and my task is to create a function that reads in an input file:

*****************
2

3
1

abc
def
ghi

/dev/sid/
*****************
(NOTE: the spaces between data sets above DOES NOT exist but it's only there for ease of understanding)

the first line (2 in this case) consists of the numbert of data sets followed by the number of parameters in the 2 datasets (3 and 1).

(abc,def,ghi) are the parameter values for the first data set and (/dev/sid) is tha value for the second data set.

The above 2 data sets need to be scanned into different arrays and hence this is what i came up with:

cat ${INPUT_FILE} | while read LINE #processing steps for all common parameters, assign each common parameters to the array variable COMMON_PARAMETER_CONTENT
do

if [[ $count -le $PARAMETER_CONTENT ]]
then
SUBSET_ARRAY[count]=$LINE
((count+=1))
continue
fi

i = 0
countA = 0
countB = 0

while [[ $countB -l (SUBSET_ARRAY[i]) ]] //need a check here to prevent overflowing..!
do
while [[ $countA -le (SUBSET_ARRAY[i]) ]]
do
[I] SUBSETDATA + "i" = $LINE
((countA+=1))
((DATA_TOTAL_LINE+=1))
done
((i+=1))
countA = 0
done

My question is.. will the highlighted, Italicised line work? Can i loop thru' and put the diff datasets into diff arrays using the "string join" ? Thanks in advance and sorry for the long post.

Sid
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:00 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0