The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
help needed in using case statement jisha Shell Programming and Scripting 0 01-16-2008 04:33 AM
It's stunning, powerful and elegant... so set the iphone free - Guardian Unlimited iBot UNIX and Linux RSS News 0 11-11-2007 06:30 AM
conditional statement lalelle Shell Programming and Scripting 8 08-21-2007 08:57 AM
quoting in conditional statement 3Gmobile Shell Programming and Scripting 2 08-14-2006 03:14 AM
awk conditional statement 3Gmobile Shell Programming and Scripting 10 08-09-2006 10:01 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 05-18-2006
candyflip2000 candyflip2000 is offline
Registered User
  
 

Join Date: Jan 2006
Posts: 6
Post more elegant way for conditional statement needed

Hi all,

I have a script which gets its input from a text file (file.txt) and processes each line within a loop.

I have a counter which increases by one and I want something to happen every 7th, 14th, 21st, etc. line read.

Currently the code looks and works perfectly like this:

------------------------------------------
count="1"

while read WORKSTATION
do
if [ $count -eq 7 ] || [ $count -eq 14 ] || [ $count -eq 21 ] ||\
[ $count -eq 28 ] || [ $count -eq 35 ] ; then

some code here ....

((count=count+1))
fi

done < file.txt ;

------------------------------------------

However, it doesn't look beautiful and with that many conditional statements (I shortened it, it goes further than just 35) I'm, looking for a more elegant solution.
I have tried this

if [ $count -eq '[7,14,21,28,35]' ] ; then

but it doesn't work...

Does anyone know the correct syntax - or is this not possible?

Many thanks in advance!

Cheers,
Tom
 

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 04:38 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