Visit Our UNIX and Linux User Community


Korn vs Bash


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Korn vs Bash
# 1  
Old 10-02-2001
Korn vs Bash

Let's say I have
Code:
alias good_op=`[[ "$sign" = "+" || "$sign" = "-" ]]`

in a Korn shell script. How can I write that in a non-interactive bash shell?
# 2  
Old 10-02-2001
Have you tried that in bash? Bash implements some of the cool features of ksh, so that entire statement (possibly even most of your script) very well may work in bash.
# 3  
Old 10-02-2001
thanks, it didn't work in bash, but I found a way around:
using test, do, and done -
Code:
test [ "$sign" = "+" -o "$sign" = "-" ]; do...

not the most elegant, but it works.
# 4  
Old 10-02-2001
I got your alias to work in bash. But when I do "bash --version", I get 2.03. I'm guessing that you are using an older version of bash.

The only feature that I miss in bash is the ksh co-process code. Once bash picks that up, I will probably switch to bash.
# 5  
Old 10-02-2001
this is my version:
GNU bash, version 2.03.8(1)-release (i386-redhat-linux-gnu)
Copyright 1998 Free Software Foundation, Inc.

The alias will only work in an interactive shell. I get an interactive shell when I login, but any script that runs will start its own non-interactive shell.

Oh, this is bash2.
# 6  
Old 10-02-2001
You're right. I tested interactively and I can't get bash to use aliases at all in a script. A more elegant work-around is to switch to functions. I think the existence of functions is why both ksh and bash have weak alias commands. The function is:

Code:
good_op() { [[ $sign = + || $sign = - ]] ; }

and yes, with the [[ command, you can drop all those double quotes you had.
 

Previous Thread | Next Thread
Test Your Knowledge in Computers #563
Difficulty: Medium
The comparison operators are only used for comparing numerical data types.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

UNIX Korn Shell to Linux Bash

Migrating Unix batch jobs (Korn Shell) running in HP-UX server to Linux environment. Hi All Please help me to understand the easiest way to migrate Kernel Shell scripts to Linux Bash. Also let me know 1. Any automated scripts or tools available for this. 2. Challenges and issues... (5 Replies)
Discussion started by: cpremesh
5 Replies

2. Shell Programming and Scripting

New to korn shell

I am new to korn shell and slowly learning. Is there a way to have a parent script prompt for input and then execute a child script and return the output then move forward and ask for more input and then execute the next child script? I think the answer is no but thought i would ask. (2 Replies)
Discussion started by: cptkirkh
2 Replies

3. Shell Programming and Scripting

Difficulty with a couple commands porting from korn shell to bash

I am relatively new to shell scripting. I have a script I wrote that works fine in korn shell. I need to make it work in bash on a different server. There are a couple valid korn shell commands I am having difficulty finding the bash equivalents for. At one point the scripts prompts the... (5 Replies)
Discussion started by: inakajin
5 Replies

4. Shell Programming and Scripting

help with korn script

Hi guys, I am new to unix scripting. I have a folder rx and it has subfolders rx1,rx2 and rx3 each subfolder has 4 directories each load,land,arch and extr I have the below tar and rm commands using wich we should write a shell script rx1-- tar -cf... (2 Replies)
Discussion started by: Kornscript
2 Replies

5. Shell Programming and Scripting

Korn/bash Script to monitor a file a check for specific data

Hi, Im trying to write this script but im stuck on it, basicaly what i want to do is to write a code to verify a log file ( apache log file for example ) and for each new line with specific data , then, output this new line for another file: full ex: output of the server.log is (... (4 Replies)
Discussion started by: Thales.Claro
4 Replies

6. Shell Programming and Scripting

korn shell

I am using korn shell but I want to have my prompt to represnent that of my C shell because I like it better. Is there anyway to do this? (1 Reply)
Discussion started by: vthokiefan
1 Replies

7. UNIX for Dummies Questions & Answers

Korn vs. Bash - which to use

Hello: I'm a newbie to Unix/Linus and shell scripting. This is probably a stupid question but here goes. Some people at work use Korn for scripting while others use Bash. What is the difference between the two? If the two is better to use? When a person logs in, one will type... (9 Replies)
Discussion started by: hbradshaw
9 Replies

8. UNIX for Dummies Questions & Answers

korn shell to bash - statement not working

Everything else seems to be working, but this isn't. Is it the "cat..." that is wrong of the condition? Thanks. cat tc_result.txt | while read LINE do if then let "files_run += 1"; echo "inside the if loop" # save current filetype case $LINE... (5 Replies)
Discussion started by: brdholman
5 Replies

9. Shell Programming and Scripting

Korn Shell

Hi I am new to shell programming. I need help to write a script to monitor a process on Sun OS. If the process fails then call a oracle procedure. i check the process if running by typing ps -ef | grep ESP | grep -v grep root 29002 1 0 Mar 18 ? 7:20... (4 Replies)
Discussion started by: gpanesar
4 Replies

10. Shell Programming and Scripting

korn syntax

Hi, how do I write this condition in korn shell: file="*.html" if then echo "$file" fi I am trying to find all html files from a input text file that were created today and ftp them to a different server. please help. (1 Reply)
Discussion started by: sajjad02
1 Replies

Featured Tech Videos