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
forcefully throwing error : unix script dr46014 UNIX for Dummies Questions & Answers 1 10-01-2008 04:42 AM
awk Shell Script error : "Syntax Error : `Split' unexpected Herry UNIX for Dummies Questions & Answers 2 03-17-2008 11:16 AM
Error while trying to fire a PL/SQL thro Unix Script dharmesht Shell Programming and Scripting 5 12-11-2003 10:10 AM
UNIX error log eysheikah Security 3 05-31-2003 09:21 AM
SCO UNIX error 6, HELP PBNOSGT UNIX for Dummies Questions & Answers 0 02-01-2002 11:46 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 03-18-2009
joyrules joyrules is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 3
Error in Unix Script

Hi!
Following is the script to find the number of users and the total space consumed by them in the directory
But I am getting few errors Pls help me
Code:
data=`ls -lt $1 |tr -t [' '] ['\t']|tr -s '\t'|cut -f3,5`

count=0

flag=1

sum=0

users_flag=1

check=0

declare -a users

for a in $data

do

	if [ $users_flag -eq 1 ]

	then

		for ((i = 0; $i <= count; $i++))

		do

			if [ $a = ${users[$count]} ]

			then

				flag=0

				break

			fi

		done

		if [ $flag  -eq 1 ]

		then

			users[$count]=$a

			count=expr`$count + 1`

			echo $a >> userdata

		fi

		users_flag=0

	else

		if [ $flag -eq 1 ]

		then

			

			for b in $data

			do

				if [ $check -eq 0 ]

				then

					if [ $b = $a ]

					then 

						check=1

					fi

				else

					sum=`expr $sum + $b`

					check=0

				fi 

			done

		fi

	fi

done

Errors are
q3: 7: declare: not found
q3: 9: Syntax error: word unexpected (expecting "do")

Last edited by joyrules; 03-18-2009 at 10:39 AM.. Reason: Formatted script
 

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 09:05 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