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
Array inside an array manas_ranjan UNIX for Advanced & Expert Users 5 06-10-2008 03:25 PM
create array holding characters from sring then echo array. rorey_breaker Shell Programming and Scripting 5 09-28-2007 09:42 AM
How big is my awk array? pondlife Shell Programming and Scripting 4 09-10-2007 01:40 PM
using array RianTan Shell Programming and Scripting 3 09-05-2005 04:47 AM
Do I need an array here? TheCrunge Shell Programming and Scripting 5 04-19-2005 04:20 PM

Closed Thread
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
  #1 (permalink)  
Old 09-28-2007
petachi petachi is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 2
Thumbs up Array help needed

I want to write a line to a log file for each mountpoint that is above 75% disk space used.

I have written the following so far which doesn't take into account the checking for 75% yet but simply tries to write a line for every mountpoint into the logfile.

#!/bin/ksh
PERCENTAGES=`bdf | grep /var/opt/ixos/ | awk '{ print $4 }'`
MOUNTPOINTS=`bdf | grep /var/opt/ixos/ | awk '{ print $5 }'`

len=${#PERCENTAGES[*]}
echo "len=$len"
i=0
while [ $i -lt $len ]
do
echo "${MOUNTPOINTS[$i]} IS ${PERCENTAGES[$i]} FULL RIGHT NOW"
(( i=i+1 ))
done
exit 0

PERCENTAGES and MOUNTPOINTS seems to get populated properly but for some reason no matter what I try the len assignment line always wants to be 0.

Even when I hardcoded len=10 (which is the number of elements both arrays are actually assigned) the loop doesn't work as desired and instead seems to print out the contents of each whole array each time they're referenced in the loop.

Any help would be appreciated as I believe it's pretty close but I'm obviously missing something.
  #2 (permalink)  
Old 09-28-2007
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,813

Code:
PERCENTAGES=`bdf | grep /var/opt/ixos/ | awk '{ printf("%s",  $4) }'`

the newlines are terminating the array early.
Closed Thread

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 05:56 AM.


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