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
0 answers

is the .ksh deleting path slashes?

Under a Windows 7 env, I have a java code that launches a .ksh script. The latter takes a path to a directory as an argument and has to create a new folder in it. The Java code: ProcessBuilder pb = create(this.shell); …
Akinn
  • 1,896
  • 4
  • 23
  • 36
0
votes
2 answers

Windows cannot run .ksh script

I have a java code under eclipse that is calling a .ksh script. The OS is Windows7. I am a complete noob in shell things and the code (both java and ksh) were not written by me (and I cannot change it). Anyway, when it tries to launch the script,…
Akinn
  • 1,896
  • 4
  • 23
  • 36
0
votes
2 answers

Bash: Capturing Output from a curl command and mapping Key Values from the output to new Key-value pairs

a curl command gives me a JSON output as follows:- [{"Description":"","Value":"bc","Key":"a"},{"Description":"","Value":"ef","Key":"d"},...] Now I want to capture the values of only "Key" & "Value" in such a way that it if I perform echo $a it gives…
Sourav Das
  • 51
  • 7
0
votes
1 answer

Why IFS impact subshell variable?

This KSH code working fine on AIX and RH with the standard IFS (default) [ "$(uname)" = "AIX" ] && ECHO="echo" || ECHO="echo -e" echo "AA BB CC DD" | while read a b c d; do [ "`$ECHO $a | cut -c1-2`" = "AA" ] && echo $b done If i set a different…
spaceworld
  • 13
  • 4
0
votes
1 answer

Tab complete second command

I am trying to get tab completion on the second atom of a command. I.e. man do In bash this can be done with complete -cf but I am not sure if this is possible in ksh. Any Ideas?
0
votes
0 answers

Environment Variables not found when running script from Jenkins

I have a script called test.sh on a remote server. It prints an environment variable that has been set in the .profile and looks like this: #!/bin/ksh echo "JAVA_HOME: $JAVA_HOME" When I run the script manually I get the same result as with an echo…
jschuebel
  • 312
  • 2
  • 15
0
votes
1 answer

Iterate over function's output

Below is the function, that gives me the directory that are greater than the value 4. (ver=4) #!/bin/ksh declare -a folders_res declare -a dirs check_minor_version(){ dirs=($(find ${my_directory}/${my_dir} -type d -printf "%f\n" | sed '1d'…
Goku
  • 482
  • 1
  • 7
  • 22
0
votes
5 answers

awk multiple row and printing results

I would like to print some specific parts of a results with awk, after multiple pattern selection. What I have is (filetest): A : 1 B : 2 I expect to have: 1 - B : 2 So, only the result of the first row, then the whole second row. The dash…
Alex
  • 47
  • 5
0
votes
1 answer

SSH with EOF correctly sets $PATH, but why doesn't it work without EOF?

I'd like to understand why ssh doesn't set the $PATH to whatever is determined in .profile, but seems to do it when ssh uses EOF. I'd like to run this line in my script: DIR_EXPANDED=`ssh $TOADDRESS "$(typeset -f get_dir); get_dir $DIR…
Michael
  • 53
  • 6
0
votes
2 answers

Way to append to file with echo command or other command without using ' ' or " "

I am trying to copy an entire script, not the script output but the entire script as a text line inside a file named test.sh. I am using another script to execute this so that is why I didn't use a text editor like vi. I can't use echo "" or echo ''…
0
votes
0 answers

Taking all logged in users and printing those who has running mail

Good mornin' So I'm trying to print all users that have mail running on their terminals. I managed to get usernames from finger and redirect it to variable 'i'. User in our system have names like d123456. for i in `finger | grep '^d......' -o`; do …
Noweli
  • 1
0
votes
1 answer

compress data into existing zipfile subdir from stdin

I know it is possible to pipe stdin into a zipfile. However, is it also possible to do this, while providing the target subdirectory of an existing zipfile? e.g., something like echo thisshouldbezipped > gzip -u mycurzipfile.zip mysubdirinzip
Rusty75
  • 477
  • 7
  • 19
0
votes
2 answers

RegEx for a multiple line search and replace using sed

I need to have a RegEx that finds a \n in the middle of a line as a start point, anything before is random, and replace after 15 digits and 49 alpha on the second line. I need to replace all that by blanks, but the second line needs to join with the…
0
votes
1 answer

Multi-variable string not being returned via SFTP get command

I'm working on a ksh script to retrieve a file every hour via sftp that will be put on a job scheduler to be run hourly. The script must navigate to a folder with yesterday's date (remote/path/yyyymmdd/). The filename also has yesterday's date and…
dcap4518
  • 3
  • 2
0
votes
1 answer

check permissions aix script

Hello I try to write script to make this "If the file exists Must be owned by a system user and group. Permissions for other must be r-x or more restrictive." Aix systems 7.2 #MODULE BODY file_path="/bin/ssh-add" if [ -e $file_path ]; then …
1 2 3
99
100