$(( .. )) is part of the POSIX specification, so in practice it should work with /bin/sh on almost any modern Unix / Linux (On Solaris <=10 use /usr/xpg4/bin/sh)
Yes and no. The POSIX Standards and the Single UNIX Specifications require that the standards-conforming shell be named sh and that it support arithmetic expansions (i.e., $(())), but the standard makes absolutely no requirement that it (or any other standard utility) exist as a file in any particular directory. There is no requirement in the standard that there be a directory named /bin nor that any utility in the standard exist in that directory. The POSIX standards leave a chicken versus egg question about how you find the standard utilities. The documentation for a conforming implementation is required to document how to find conforming utilities on that implementation. Once you know the absolute pathname of the conforming getconf utility, the command:
will return a set of directories that can be placed at the front of your setting of $PATH that will find all of the standard utilities. If your implementation concurrently supports more that one standards conforming environment (such as Solaris systems), there will be more than one standards conforming version of getconf (at least one for each environment supporting standards with conflicting requirements). On Solaris systems, /usr/bin/getconf gives you an environment that conforms to System V Interface Definition Issue 3 (SVID3) and X/Open Portability Guide Version 3 (XPG3); /usr/xpg4/bin/getconf gives you an environment that conforms to POSIX.2, POSIX.2a, Single UNIX Specification original version (SUS), SUSv2, and XPG4; and /usr/xpg6/bin/getconf gives you an environment that conforms to POSIX.1-2001 and SUSv3. More details on how Solaris Systems support multiple standards concurrently can be found in the OpenSolaris STANDARDS(5) man page in the man page sets provided on this site.
Hi, yes, but that is why I wrote "in practice". Of all the current Unixen that aspire to be POSIX compliant, Solaris < Version 11 is one of the few (how many others are there?) that does not have a POSIX compliant shell (or a near compliant one) as /bin/sh (even though this is not required or even specified by the standard). So I agree it is best to not rely on this and not specify a shebang and use the proper getconf, but in practice this should work (with the exception mentioned above)..
Last edited by Scrutinizer; 12-11-2012 at 04:25 PM..
hello
i have obtained the current date ..
current_date=date "+%m/%d%y"
and i have another date ,stored in my log file which i have already retrieved. i want to store the subtraction in a varible called diff.
diff=log_date - currentdate
ex: log_date=01/28/11
current_date=... (3 Replies)
Gents,
I have been working in a Solaris/Unix environment for about 9 months. I took some linux classses online before getting the job. But, I am not very good at scripting. I want to learn how to script. Do you think that I should start with Shell scripting or Perl? I wanted to continue with... (2 Replies)
Hi all,
I would like to start developping some good scripting skills. Do you think it would be best to start with shell scripting or Perl? I already got a fundation, really basics, in perl. but I am wondering what would be best to be good at first.
Can you please help me determine which one to... (14 Replies)
Hi
How to call a shell scripting through a Perl scripting? Actually I need some value from Shell scripting and passes in the Perl scripting. So how can i do this? (2 Replies)
Hi all,
I have in one script something like this:
FIRSTOCC=`grep -n ORA- alert_bill2.log |tail -"$ROWS"|head -1|cut -d: -f1`
TOTAL=`more alert*|wc -l`
DIFFERENCE=`$TOTAL-$FIRSTOCC`
echo Total lines in alert_bill = $TOTAL
echo $DIFFERENCE
How do I make this substraction work?
Thk (2 Replies)