- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: for (int i = 200; i > 10; i++)
Categories
Company
Local Language
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
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
Community
Resources
Forums
Blogs
- 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
04-17-2003 03:51 AM
04-17-2003 03:51 AM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2003 03:58 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2003 03:58 AM
04-17-2003 03:58 AM
Re: for (int i = 200; i > 10; i++)
If so:
i=10
while (( i < 201 ))
do
print -n $i
(( i=i + 1 ))
done
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2003 04:00 AM
04-17-2003 04:00 AM
Re: for (int i = 200; i > 10; i++)
I assume your construct means to start i with a value of 10, and increment it by one until it is greater than 200. Your syntax looks backwards, but if I understand what you are asking, here is one way to do it in some ksh script code:
let i=10
while (( $i < 200 ));
do
let i=i+1
echo $i
done
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2003 04:00 AM
04-17-2003 04:00 AM
Re: for (int i = 200; i > 10; i++)
You can use if commands to do the same in shell scripts. Also while ...do ...done is another option.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2003 04:06 AM
04-17-2003 04:06 AM
Re: for (int i = 200; i > 10; i++)
As far as I know "for (int i = 200; i > 10; i++)" means:
1) i=200 (integer value)
2) if "i" > 10, then do list of commands and increment "i" by one.
This loop will never end unless "i" should be "i-1" in the loop.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2003 04:11 AM
04-17-2003 04:11 AM
Re: for (int i = 200; i > 10; i++)
Exactly. That's why I commented that his syntax looks backwards. I assume he intends to start i at 10 and increment by one to 200, but the way it is written it would be an infinite loop. Sometimes we just have to guess at what people are really asking. :)
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2003 04:14 AM
04-17-2003 04:14 AM
Re: for (int i = 200; i > 10; i++)
Absolutely! I didn't read your first reply carefully :(( I think your guessing was right.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2003 04:27 AM
04-17-2003 04:27 AM
Re: for (int i = 200; i > 10; i++)
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2003 04:28 AM
04-17-2003 04:28 AM
Re: for (int i = 200; i > 10; i++)
I was'nt looking for syntactical answers, jut the meat.
peace
Donny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2003 05:05 AM
04-17-2003 05:05 AM
Re: for (int i = 200; i > 10; i++)
First it is proprietary software, second there is a far more powerful OpenSource alternative, viz. Bash.
In Bash you can exactly use the C-like idiom, you were suggesting.
e.g. count from 10-20
$ echo $0
bash
$ for ((i=10; i<=20; i++)); do printf "%4u\n" $i; done
10
11
12
13
14
15
16
17
18
19
20