Questions tagged [ksh]

The KornShell is an open source, POSIX-compatible shell language from AT&T based upon the original Bourne shell. Make sure you know whether your ksh is ksh93 or a clone.

The KornShell was created by David Korn at AT&T. It was created at Bell Labs (then AT&T) as a logical successor to the Bourne shell as the UNIX command line interpreter and scripting language.

The KornShell is compatible in syntax with the original Bourne shell and adds several features, like an interactive command line editor, functions with local variables, and arithmetic.

History

The KornShell was originally distributed as part of the AT&T Toolchest in the early 80's.

There are many different versions of the KornShell, and it can make a difference to know what they are.

Ksh93 is currently at version [ksh93u+] (For a long time it was distributed by AT&T, now it has moved to GitHub https://github.com/att/ast) and distributed under the Eclipse Public License as part of the AST (AT&T Software Tools) project staffed by David Korn and Glenn Fowler.

  • Ksh93 precursor ksh88 was the last official version of the KornShell in the AT&T Toolchest.
  • Mortice Kern Systems ported ksh88 to DOS/Windows, and adopted by Microsoft into its UNIX toolsuite for windows. Microsoft eventually shifted to Interix for its UNIX toolsuite.
  • UNIX vendors incorporated ksh88 into their product and enhanced it (Sun Microsystems added internationalisation).
  • pdksh was distributed for UNIX (like) systems, but missed some features of the original.
  • mksh is the contemporary successor of pdksh; David Korn agreed it’s a good thing as long as it cannot be confused with the original ksh, so please add the tag for questions related to it (it’s on-topic in most ksh-related places)
  • ksh93 has been under development by the AST team since its inception, with roughly 1 major update per year. For a long time ksh93 was only available commercially, but eventually was open-sourced.

Features

The following list includes features of ksh88 and ksh93

  • command line editing - vi or emacs mode
  • command line history - use vi/emacs/arrow keys to recall earlier commands

  • Functions

  • local variables in functions
  • arithmetic (( ... )) and $(( ... ))
  • floating point arithmetic (since ksh93)
  • builtin replacements for many standard unix commands

Standardization

The KornShell (ksh93) was at the basis of the POSIX sh standard, although not all ksh93 features are included, and some posix shell features are optional.

2730 questions
0
votes
1 answer

How to add sequential numbers say 1,2,3 etc. to each file name and also for each line of the file content in a directory?

I want to add sequential number for each file and its contents in a directory. The sequential number should be prefixed with the filename and for each line of its contents should have the same number prefixed. In this manner, the sequential numbers…
fashion123
  • 21
  • 1
  • 4
0
votes
1 answer

Unable to use variable in curl command

I'm trying to use two variables in a curl command on my ksh program, but it doesn't work. Example: Original URL curl -s --header "Content-Type:application/json" --header "Accept:application/json" -X POST --data-binary…
Loudone
  • 309
  • 1
  • 2
  • 10
0
votes
2 answers

replace string rsubmit with * rsubmit

I have text files with lines like these: -------------------------- .... ... rsubmit; ........ ........ endrsubmit; ....... ...... rsubmit ; ................ ....... endrsubmit ; .......... ----------------------------- I…
Alvin SIU
  • 1,022
  • 10
  • 28
0
votes
0 answers

Reading lines from file and assigning into variables using ksh

I have a text file which looks like this: John 25 Football I have to read this file using shell script and I will be having 3 variables as name, age and passion in my script. I have to read the above text file and have to set name as "John", age as…
Sheik
  • 1
0
votes
2 answers

How to get last part of string in substring by variable number of delimiters

I am struggeling a bit. As I write a ksh script I need to extract a Substring of a String where the number of occurances of the dilimiter is flexible. This is, as my String holds the name of a file which might be compressed several times,…
Yonkske
  • 13
  • 4
0
votes
3 answers

just one record per group on each line

let's say I have a following file named groups.txt containing: aaa: bbb:11,22 ccc: ddd:44,11 I need to write a ksh command / script to display every record for every corresponding group just once pre row. Expected…
Juraj
  • 3
  • 1
0
votes
1 answer

Getting pids in an array in ksh script

I am creating a script using ksh where a process (simple_script.sh) is executed and iterates 5 times. What I need to do is get the pid each time the process is executed and store them in an array. So far I can get the script to execute…
hanktank45
  • 19
  • 3
0
votes
2 answers

Unix - Remove internal double quote with terminator comma

Input file: "1","2col",""3col " " "2","2col"," "3c,ol " " "3","2col"," 3co,l" "4","2col","3co,l" "5","2col",""3co,l "" " "6","2col",""3c,ol ""3c,ol""" Output file: "1","2col","3col " "2","2col"," 3c,ol …
swet
  • 207
  • 4
  • 15
0
votes
2 answers

Shell variable value substitution

Heres the description of my issue, I have a while loop that takes values from a file while read table do schema="$(echo $table | cut -d'.' -f1)"; tabname="$(echo $table | cut -d'.' -f2)"; echo "$schema"; echo "$tabname"; echo…
d0dulk0
  • 112
  • 2
  • 8
0
votes
1 answer

What this symbol mean "#?" in ksh

What does "#?" mean in ksh script? e.g: tt=03 while [ "$tt" !=' ' ]; do tt=${tt#"?} done echo $tt I will get nothing here. So what "#?" means in this scipt? Thank you.
kelly
  • 91
  • 7
0
votes
1 answer

UNIX ksh Programming

I have a | delimited file with 132 fields in every record, what I need to do is append the last 2 bytes in field 3 to field 1 than print the entire record: example of the input record field1 field2 field3 field4 field5 .... field 132 123456 xyz…
0
votes
1 answer

variable part in a variable path in ksh script

I'm sorry if something similar was already answered in the past, but I wasn't able to find it. I'm writing a script to perform some housekeeping tasks, and I get stuck in the step below. To put you in the record, it's a script which reads a config…
jota
  • 1
0
votes
4 answers

How to loop comma separated values in shell script

I tried to loop comma separated values with space, but not able to get the exact value since it has space in the string. I tried in different ways, but i not able to get desired results. Can anyone help me on this #!/bin/ksh values="('A','sample…
Gowtham
  • 1
  • 1
  • 5
0
votes
0 answers

return only value from a function of a shell script to another shell script

I have one script name check.ksh which will check some functionality and having different functions for that: !/bin/ksh print "start" val1=$1 val2=$2 func=$3 checkfunc() { if [[ $val1 != $val2 ]] then print "argument differs" …
Sann
  • 41
  • 5
0
votes
2 answers

How to run multiple SQL script files in a Shell script

I have to create 1 UNIX Shell script. In that shell script i want to run multiple SQL script files from the same directory. I have used like this- #!usr/bin/ksh SQLPATH = /usr/sql/ (cd $SQLPATH; 'sqlplus usr/password@sid <.log …
Shahin P
  • 372
  • 1
  • 4
  • 14
1 2 3
99
100