Is there a way to implement the following using 'for' in KornShell (ksh)? Here is the C equivalent:
for(i=1;i<20;i++)
{
printf("%d",i);
}
I was wondering if this can be implemented using just 'for' and not 'while'
I tried the following, it does not seem to work.
for i in [1-20]
do
print $i
done
Please let me know your ideas and solutions.
Not really an answer, but an FYI to casual ksh users.
Edit 2019-05-12 (Minor edits below in bold, other info is now stricken).
To clarify on several comments here, there are 2 ksh's available in typical vendor installations (non-Linux (maybe them too?)).
Solaris and AIX have a ksh and ksh93 (probably true for other vendors too). The base ksh is also known as ksh88. Ksh93 is described in The New Kornshell Command and Programming Language, 1995
Linux systems that have a true ksh (not pdksh), mostly use ksh93 named as ksh.
Finally, to further confuse things, don't let the 1995 pub date trick you, ksh continues under was under active development by David Korn and Glen Fowler at AT&T until 2012?. Versions were released 2-3X per year. Some Linux versions pick up the newer versions.
These newer versions have very advanced features
(most of this taken from AT&T research UWIN page. search for the link 'notes and changes' (dead link) )
(note that ...s in above, usually indicate some qualifying information removed)
Korn and Fowler had also produced an advanced environment, UWIN (Unix for Windows) for people that use systems like Mingw or Cygwin, that would be worthy of a separate post. The downside for UWIN is,
See UWin main page (dead link) : unfortunately out of date, better to nose around in the dnld link above. Hmm, this is much better Glenn Fowler's FAQ for UWin (also dead, Time Machine anyone?).
I hope this helps!
Edit 2019-05-12 . The reason for the dead links? David Korn and Glen Fowler Laid Off (at AT&T, 2012?
Information later surfaced that they are working at Google. I can't confirm this, so consider it as an old rumor.
AND see Is Ksh93 dead?
There still seems to be some activity at the ast git-hub site . ast is the over-arching package that includes ksh93. You can get the fresh source code there and compile it.
Here is the text of the project description. (There is considerably more information in the README.md).
KSH93
This repository contains the AT&T Software Technology (AST) toolkit from AT&T Research. As of November 2017 the development focus has been shifted to the ksh (or ksh93) command and supporting code required to build it.
The non-ksh code of the AST project is no longer being actively maintained. If you are interested in the non-ksh code see below for details on which branches contain the full AST code base.
The project only supports systems where the compiler and underlying hardware is ASCII compatible. This includes Linux on IBM zSeries but not z/OS. The nascent, incomplete, support for EBCDIC has been removed. See issue #742.
* The EPL replaced AT&T's original CPL.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With