Sponsored Content
Full Discussion: POSIX compliance...
Operating Systems OS X (Apple) POSIX compliance... Post 302976886 by Don Cragun on Thursday 7th of July 2016 02:24:13 PM
Old 07-07-2016
Some shells (such as bash and 1993 or later versions of ksh) provide:
Code:
for((n=1; n<=100; n++))
do	echo "process n=$n"
done

but this is an extension that is not yet specified by the standards. As you said, standard ways to do the same thing require an initialization step before the loop, such as in:
Code:
n=1
while [ $n -le 100 ]
do	echo "process n=$n"
	n=$((n + 1))
done

and in:
Code:
n=0
while [ $((++n <= 100)) -eq 1 ]
do	echo "process n=$n"
done

Note: As noted by Scrutinizer in post #8, the POSIX standards do not require $((++n)) to work. (It works with a recent bash and with a 1993 or later version of ksh, but is an extension to the requirements specified by the standards.)
Code:
n=0
while [ $(((n += 1) <= 100)) -eq 1 ]
do	echo "process n=$n"
done

should work in an POSIX-conforming shell.

Last edited by Don Cragun; 07-10-2016 at 04:56 PM.. Reason: Add note.
This User Gave Thanks to Don Cragun For This Post:
 

5 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

sudo & Sox compliance

Hello, I am trying to convince my boss to stop allowing our users to login as root (superuser). Currently our users login to our unix server with their own account, then as needed, they will do an su and put in the root password. This scares me, for a bunch of reasons. Mainly, one is that we... (1 Reply)
Discussion started by: rwallaceisg
1 Replies

2. UNIX for Dummies Questions & Answers

man synopsis standard compliance

In different online sources, I found bits and pieces of information about those square and angular brackets and pipes. From what I have read, I can conclude it looks like this: 1. Options outside any brackets are mandatory 2. Options inside these < .. > are mandatory too 3. Options inside ... (4 Replies)
Discussion started by: vkleban
4 Replies

3. Cybersecurity

PCI DSS Compliance : Insecure Communication Has Been Detected

From the nessus scanner tool report i got below vulnerability PCI DSS Compliance : Insecure Communication Has Been Detected http://www.tenable.com/plugins/index.php?view=single&id=56208 As per the description given in above link - I am not able to understand How to find insecure port... (2 Replies)
Discussion started by: saurabh84g
2 Replies

4. Red Hat

Looking for PCI Compliance tool for Redhat Lix.

Hi i am in new to Linux world . I have been assigned to a project to find out a tool that will fulfill the PCI compliance for Linux servers for Audit process. anyone have any recommendation on that. Do Rad hat have any native application or plug-ins which we can use for that. (1 Reply)
Discussion started by: sahasuman
1 Replies

5. HP-UX

Password compliance setting

I need to set password compliance for some servers in my company. However, the requirements are that we need to set different password policies for 3 different user groups within the company. These are : System Users: i.e root, etc Batch/Application Users: oracle, bscs, etc Standard User:... (0 Replies)
Discussion started by: anaigini45
0 Replies
Dancer::Timer(3pm)					User Contributed Perl Documentation					Dancer::Timer(3pm)

NAME
Dancer::Timer - a timer for Dancer SYNOPSIS
use Dancer::Timer; my $timer = Dancer::Timer->new(); my $time = $timer->tick; print "[$time]: Doing something "; # (time passes) $time = $timer->tick; print "[$time]: Doing something else "; # (time passes) $time = $timer->to_string; print "[$time]: Doing another thing "; DESCRIPTION
Dancer::Timer provides Dancer with a timing object to clock operations. For example, you might want a logging that shows you when each operation happened (at what time) to determine how long each operation was in order to know where to focus on for possible bugs or perhaps unnecessary slowness. Dancer uses Dancer::Timer in facilities that want to provide this for you. Any plugin author is more than welcome to use it as well. ATTRIBUTES
start_time Retains the starting time of the timer. The default value is when the object is created. It fetches that using "gettimeofday" from Time::HiRes. METHODS
init This method is called when "->new()" is called. It initializes the "start_time" attribute. tick Creates a tick in the timer and returns the interval between the "start_time" and now. to_string Same as "tick", just more expressive. AUTHOR
Alexis Sukrieh LICENSE AND COPYRIGHT
Copyright 2009-2010 Alexis Sukrieh. This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. See http://dev.perl.org/licenses/ for more information. perl v5.14.2 2012-01-28 Dancer::Timer(3pm)
All times are GMT -4. The time now is 06:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy