|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Bash to ksh problem
Hi all Below code works in bash but it is not working in ksh. Code:
enddate=`date -d "$enddate + $i day" "+%Y_%m_%d"` Please help me how it works in ksh Thanks Last edited by pmreddy; 01-21-2013 at 04:50 AM.. |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Replace shebang
#!/bin/bash to
#!/bin/ksh -xv (set xtrace & verbose) and run the code to reveal lines that are not KSH compliant. For example, I see you are using string search and replace which I guess is not supported in KSH. Code:
startdate="${1//_/-}" # change underscores into dashesUse sed instead to perform search and replace. |
| Sponsored Links | ||
|
|
#3
|
||||
|
||||
|
Quote:
@OP: Which ksh version are you using? Are you running this on some machine not having GNU date installed? |
|
#4
|
|||
|
|||
|
I'd also replace the "echo"s with "print"s. "print" is a built-in command in ksh, while "echo" isn't. What is equally ugly in ksh and in bash is this: Code:
while [ 1 ] It will work, but will use "test" to do so. Instead Code:
while : will do the same with less resources used. I hope this helps. bakunin |
| Sponsored Links | |
|
|
#5
|
||||
|
||||
|
@Bakunin, can you site a version of ksh where echo is not builtin?
I have 11/16/88, 12/28/93 and mksh 41 and it appears to be builtin in all of these. |
| Sponsored Links | |
|
|
#6
|
|||
|
|||
|
It might be built in but this is not required by the standard. The standard output command in ksh is "print" and if you use "echo" the shell executes "/bin/echo" if it is not built in. In the AIX ksh (a ksh88) this used to be so, but to be honest i haven't checked that lately.
bakunin |
| The Following User Says Thank You to bakunin For This Useful Post: | ||
Chubler_XL (01-20-2013) | ||
| Sponsored Links | |
|
|
#7
|
||||
|
||||
|
Thanks, that might explain why a lot of the old AIX ksh scripts we have around here use print (I've always replaced them with echo or printf, whenever making updates - just because it's more portable).
|
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Ksh to bash then back to ksh | sukhdip | Shell Programming and Scripting | 4 | 01-31-2012 03:09 AM |
| Typeset conversion problem from ksh to bash | kanagaraj | Shell Programming and Scripting | 3 | 03-05-2010 10:14 AM |
| bash preferred or ksh with bash features | mrwatkin | UNIX for Dummies Questions & Answers | 2 | 06-17-2009 01:19 PM |
| bash & Ksh loop problem | zedex | Shell Programming and Scripting | 1 | 04-08-2009 09:15 AM |
| bash and ksh: variable lost in loop in bash? | estienne | Shell Programming and Scripting | 2 | 08-25-2008 02:09 PM |
|
|