HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- generating delay based on the counter value
Operating System - HP-UX
1831309
Members
3204
Online
110023
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2004 11:15 AM
02-23-2004 11:15 AM
Hi,
I have the following script:
c=1
while [ $c -le 3000 ]
do
cat ${myfile}|while read A B
do
"something"
c=`expr $c + 1`
echo $c
done
done
I want to generate 1 sec delay for every 200th count of the counter. Can anyone please help me in accomplishing the task.
Thanks,
Andy
I have the following script:
c=1
while [ $c -le 3000 ]
do
cat ${myfile}|while read A B
do
"something"
c=`expr $c + 1`
echo $c
done
done
I want to generate 1 sec delay for every 200th count of the counter. Can anyone please help me in accomplishing the task.
Thanks,
Andy
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2004 11:54 AM
02-23-2004 11:54 AM
Solution
c=1
while [ $c -le 3000 ]
do
cat ${myfile}|while read A B
do
"something"
c=`expr $c + 1`
if [ $c -eq 200 ]
then
sleep 1
fi
echo $c
done
done
You can reset the counter if you intent is to do that or you can do some division to see if the number is divisible by 200. You you can set a second counter like this.
c=1
d=1
while [ $c -le 3000 ]
do
cat ${myfile}|while read A B
do
"something"
c=`expr $c + 1`
d=`expr $d + 1`
if [ $d -eq 200 ]
then
d=1
sleep 1
fi
echo $c
done
done
Do note that this expression type is considered obsolete:
d=`expr $d + 1`
It should be d=$(expr $d + 1)'
For new scripts.
while [ $c -le 3000 ]
do
cat ${myfile}|while read A B
do
"something"
c=`expr $c + 1`
if [ $c -eq 200 ]
then
sleep 1
fi
echo $c
done
done
You can reset the counter if you intent is to do that or you can do some division to see if the number is divisible by 200. You you can set a second counter like this.
c=1
d=1
while [ $c -le 3000 ]
do
cat ${myfile}|while read A B
do
"something"
c=`expr $c + 1`
d=`expr $d + 1`
if [ $d -eq 200 ]
then
d=1
sleep 1
fi
echo $c
done
done
Do note that this expression type is considered obsolete:
d=`expr $d + 1`
It should be d=$(expr $d + 1)'
For new scripts.
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2004 04:47 PM
02-25-2004 04:47 PM
Re: generating delay based on the counter value
I've always been fond of the modulus, so how about this:
c=1
while [ $c -le 3000 ]
do
cat ${myfile}|while read A B
do
"something"
c=$(expr $c + 1)
[ $(expr $c % 200) -eq 0 ] && sleep 1
echo $c
done
done
This way, the sleep only happens when the remainder of $c / 200 is 0.
Regards,
Seth
c=1
while [ $c -le 3000 ]
do
cat ${myfile}|while read A B
do
"something"
c=$(expr $c + 1)
[ $(expr $c % 200) -eq 0 ] && sleep 1
echo $c
done
done
This way, the sleep only happens when the remainder of $c / 200 is 0.
Regards,
Seth
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP