Sponsored Content
Full Discussion: Bash to ksh problem
Top Forums Shell Programming and Scripting Bash to ksh problem Post 302758635 by Yoda on Sunday 20th of January 2013 10:24:15 AM
Old 01-20-2013
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 dashes

Use sed instead to perform search and replace.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Ksh vs Bash

Hi Buddy, Can any one help me to overcome from the below problem? #/usr/bin/ksh typeset -Z dd dd=1 echo $dd =========== out put for the above is 01 same script I'm migrating to bash but typeset -Z option is not found in bash, Pls get me the equivalent option in BASH Thanks in... (1 Reply)
Discussion started by: krishna
1 Replies

2. Shell Programming and Scripting

Need help : KSH>BASH

Hello, I've written a script in KSH, but now it needs to run on a system without KSH, ie sh or bash etc, bash seems best bet, but the simplest of things don't seem to work.. The snippet below is the main issue, basically I'm reading from a dat file and putting fields into arrays.. Dat file... (5 Replies)
Discussion started by: itsupplies
5 Replies

3. Shell Programming and Scripting

bash and ksh: variable lost in loop in bash?

Hi, I use AIX (ksh) and Linux (bash) servers. I'm trying to do scripts to will run in both ksh and bash, and most of the time it works. But this time I don't get it in bash (I'm more familar in ksh). The goal of my script if to read a "config file" (like "ini" file), and make various report.... (2 Replies)
Discussion started by: estienne
2 Replies

4. Shell Programming and Scripting

ksh to bash mode

Hi guys... I have a ksh shell by default, so when I login to my unix box, all my .profile statements gets executed(including the aliases). But for some reasons(may be not comfortable using ksh), I would always switch to BASH(in the same session but as a child process) but in the process I am... (16 Replies)
Discussion started by: anduzzi
16 Replies

5. Shell Programming and Scripting

bash & Ksh loop problem

hi i was trying to optimize one script and i came across this problem .. i am putting some pseudo code here $ >cat a.sh ls | while read I do i=$(($i + 1)) done echo "total no of files : " $ >ksh a.sh total no of files : $ >bash a.sh total no of files : why is... (1 Reply)
Discussion started by: zedex
1 Replies

6. Solaris

ksh vs bash

Hi, I've a general question regarding shell. I 've seen that every where i worked in production environment people are using ksh .. but i like to use .. bash .. is there any particular reason why hardcore sysadmins use ksh ? (8 Replies)
Discussion started by: fugitive
8 Replies

7. UNIX for Dummies Questions & Answers

bash preferred or ksh with bash features

I'm a user on a fairly locked down sys V server. By default, I have ksh set as my default shell. I added to my .profile: bash -o vi so when I login, it goes into bash so I can take advantage of tab completion and use the up key to bring up previous commands. However, whenever I want to exit, I... (2 Replies)
Discussion started by: mrwatkin
2 Replies

8. Shell Programming and Scripting

Typeset conversion problem from ksh to bash

Hi, typeset -l sgf # all lowercase letters typeset -u SGF # all uppercase letters sgf=$1 SGF=$sgf these lines used in my scripts . It ran fine in ksh but when we convert this to bash it erroring out. I like to know what the use of typeset ?? Thanks & Regards kanagaraj (3 Replies)
Discussion started by: kanagaraj
3 Replies

9. Shell Programming and Scripting

ksh vs bash

what is diff between KSH and Bash can you tell me some commands which run in either of two but not in both. while doing normal shell programming I am unable to find diffrence between two (2 Replies)
Discussion started by: pasricha.kunal
2 Replies

10. Shell Programming and Scripting

BASH to KSH

I have a script in KSH and now need to incorporate this into another script which is in BASH. OUr script contains code like below in good number of places. Eg: echo “A B C” | read VAR1 VAR2 VAR3 This works only in ksh and not in BASH. Please let me know 1. Which is the equivalent... (3 Replies)
Discussion started by: cvsanthosh
3 Replies
QSUBST(1)						    BSD General Commands Manual 						 QSUBST(1)

NAME
qsubst -- query-replace strings in files SYNOPSIS
qsubst str1 str2 [flags] file [file [...]] DESCRIPTION
qsubst reads its options (see below) to get a list of files. For each file on this list, it then replaces str1 with str2 wherever possible in that file, depending on user input (see below). The result is written back onto the original file. For each potential substitution found, the user is prompted with a few lines before and after the line containing the string to be substi- tuted. The string itself is displayed using the terminal's standout mode, if any. Then one character is read from the terminal. This is then interpreted as follows (this is designed to be like Emacs' query-replace-string): space Replace this occurrence and go on to the next one. . Replace this occurrence and don't change any more in this file (i.e., go on to the next file). , Tentatively replace this occurrence. The lines as they would look if the substitution were made are printed out. Then another character is read and it is used to decide the result as if the tentative replacement had not happened. n Don't change this one; just go on to the next one. ^G Don't change this one or any others in this file, but instead simply go on to the next file. ! Change the rest in this file without asking, then go on to the next file (at which point qsubst will start asking again). ? Print out the current filename and ask again. The first two arguments to qsubst are always the string to replace and the string to replace it with. The options are as follows: -w The search string is considered as a C symbol; it must be bounded by non-symbol characters. This option toggles. ('w' for 'word'.) -! -go -noask Enter ! mode automatically at the beginning of each file. -nogo -ask Negate -go, that is, ask as usual. -cN (Where N is a number.) Give N lines of context above and below the line with the match when prompting the user. -CAN (Where N is a number.) Give N lines of context above the line with the match when prompting the user. -CBN (Where N is a number.) Give N lines of context below the line with the match when prompting the user. -f filename The filename argument is one of the files qsubst should perform substitutions in. -F filename qsubst reads filename to get the names of files to perform substitutions in. The names should appear one to a line. The default amount of context is -c2, that is, two lines above and two lines below the line with the match. Arguments not beginning with a - sign in the options field are implicitly preceded by -f. Thus, -f is really needed only when the file name begins with a - sign. qsubst reads its options in order and processes files as it gets them. This means, for example, that a -go will affect only files named after the -go. The most context you can get is ten lines each, above and below. str1 is limited to 512 characters; there is no limit on the size of str2. Neither one may contain a NUL. NULs in the file may cause qsubst to make various mistakes. If any other program modifies the file while qsubst is running, all bets are off. AUTHORS
der Mouse <mouse@rodents.montreal.qc.ca> BSD
September 4, 1999 BSD
All times are GMT -4. The time now is 03:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy