The Korn shell (ksh) is a shell with advanced scripting features, commonly found on commercial unices and some BSD systems but rarely used on Linux.

learn more… | top users | synonyms

1
vote
1answer
22 views

Issue with resize and stty on remote ssh script?

Scenario: Source host (Solaris 5.10, KSH), im trying to run the following script named sample.ksh on source #!/bin/ksh set -x Rediscover () { ssh user@hostB ./scripts/test.ksh } Rediscover exit 0 ...
-2
votes
1answer
44 views

KSH for generating 'n' of rows for a table dynamically : Issue with if else statement

I need to generate billion of records in a text file for table loading purpose. My destination table defination is: CREATE TABLE txnrecords12( txnno int, txndate string, custno int, ...
0
votes
4answers
32 views

Alias for listing top file and directory consumption - shortest way?

function isaix { echo "alias d='du -sm -- * 2>/dev/null | sort -nr | head -20'" >> ~/.kshrc; } function islinux { echo "alias d='du -sm -- * 2>/dev/null | sort -nr | head -20'" >> ...
0
votes
2answers
67 views

How to cut every line from a particular string?

input.txt: john_Apple01_xyz_1 john_Fruit_Apple01_abc_c1 john_Apple21_trs_1 john_Fruit_Apple21_efg_1 john_Fruit_Apple21_tefg_1 Desired output: Apple01_xyz_1 Apple01_abc_c1 Apple21_trs_1 ...
0
votes
2answers
50 views

command not found error after giving permission to access file using chmod

I've been trying to run a script using chmod. Here's how I tried to execute the script: $ chmod u+x tester $ ./tester ./tester: Command not found. I always get the Command not found error and I'm ...
1
vote
2answers
25 views

How to get the previously used command in HP-UX reverse search

I'm using HP-UX OS and want to use previously typed command, as how I'm using in Linux Ctrl+r for ease access in the HP-UX command line.
1
vote
1answer
46 views

Bash - Running a bash script from within a ksh script

I am on RHEL 6.7 and have a korn shell script that does check pre-reqs, prepares the system for rpm install's (creating directories if they are not already that are required by the product), stops ...
0
votes
1answer
22 views

cannot reload .profile from script

I am trying to reload .profile from the below script, but that doesn't work at all. #!/bin/ksh sed -i '/export rel=Rel1510_Linux/c\export rel=Rel1602_MX' ~/.profile source ~/.profile When I run ...
1
vote
1answer
21 views

Return long integer value from a function in ksh

I use the below function in ksh to return the long value of date parts function convert_date_to_long { long_date="${1}${2}${3}" return $long_date; } but the result i get is 209 when i ...
0
votes
4answers
42 views

Return value from a subscript in ksh

I want to call a script from inside a script like below weeknum=$(getweek ) Here getweek is a script file. How to write the sub script file so that it returns the value to weeknum. Should i use ...
3
votes
1answer
32 views

Opening more than 10 file descriptors with ksh

The shell syntax for opening a file for writing and using its file descriptor is: exec 3>output.log With bash and zsh you also can write: exec 13>output.log Thus, later in your script you ...
1
vote
1answer
35 views

alias su='su -' in .kshrc

I'm on OpenBSD 5.8, new to ksh and I put the string alias su='su -' in my .kshrc file as the only line. After logging in via ssh alias su gives me su alias not found and $(cat .kshrc) ...
-1
votes
1answer
49 views

How to change shell from script

I want to change shell from ksh to bash and source the .kshrc file. I want to execute following lines of command sequentially: bash . ~/.kshrc clear Can anybody help me?
1
vote
0answers
23 views

Background processes in ksh script are disappearing after they are kicked off

I'm having an issue with a KSH script that is supposed to kick off four processes in parallel in the background and then poll their status. Put simply, running the four processes sequentially would ...
1
vote
0answers
49 views

Siemens NX 10 installation: Could not determine filesystem containing /usr/ugs100

I debug script to install Siemens NX 10 applications for Debian 8.2, and get the warning: Could not determine filesystem containing /usr/ugs100 space calculations may be incorrect. The source ...
2
votes
1answer
23 views

how to differentiate error returned while reading and for EOF in shell script

I have this task of uploading a delimited file and processing it. Once the processing is done, i either say its successful and if parsing fails, i need to throw the error. I'm reading this file line ...
1
vote
2answers
158 views

cat command is not working inside shell script

I have the following line which is not working in ksh but works fine in sh cat `find /home/peter/databases -name "cells.txt"` This is working if this line is inside /usr/bin/sh script. But not when ...
2
votes
1answer
15 views

Script to see /mysqlshare is present in all list servers, doing only first iteration

I need to get /mysqlsharedetails from all the MySQL servers. I have written a script using a while read loop, but it's getting the details of only the first server, #!/bin/ksh ...
2
votes
1answer
84 views

ksh: for loop to loop through files in a particular directory

schema_dir=schema_app for SCHEMA_CHANGE in $schema_dir/* do so my pwd is /A/B/C/scripts within which I have subdirectories (schema_app, schema_data, etc). I want a for loop to run through the files ...
2
votes
1answer
38 views

How to know log the full script name executed by user?

I want to log the full name of the script executed by the user including the options/arguments he provided to that script. I was able to achieve some success using basename and whoami but it does not ...
35
votes
4answers
5k views

Is the shell ksh93 dead?

On 10/1/2013 Glenn Fowler posted this to the ast-users mailing list: As has been pointed out several times on the AST and UWIN lists, AT&T gives very little support to OpenSouce software, ...
9
votes
7answers
290 views

Check variable is an array in Bourne like shell?

In Bourne like shell which support array variable, we can use some parsing to check if variable is an array. All commands below were run after running a=(1 2 3). zsh: $ declare -p a typeset -a a ...
5
votes
3answers
104 views

Is “Arithmetic Expansion” the expected action on vars inside `[[` tests?

This script: a=2 [[ "$a" -eq 2 ]] && echo yes1 [[ $a -eq 2 ]] && echo yes2 [[ a -eq 2 ]] && echo yes3 [[ "a" -eq 2 ]] && echo yes4 Does not work in dash (and ...
0
votes
1answer
47 views

Color encoding for shell script

I using KSH shell as my linux environment. I am writing shell script for one of my project. Currently shell script does not shows color encoding for variable ,etc. It comes in black and white mode. ...
1
vote
1answer
45 views

set -A command not running in Linux

if [ $UNITS = day ]; then while ((OFFSET > 0)); do if (( OFFSET >= day )) ;then month=$((month - 1)) if (( month == 0 )) ;then year=$((year - 1)) ...
0
votes
1answer
31 views

removing all tabs in sqlplus

I can resolve this problem, but I don't understand, why happen this... My task is: (in ksh) 1st step: Query a number from a DB with sqlplus, 2nd step: Format some text for a mail, 3rd step: send a ...
2
votes
2answers
144 views

exit trap in dash vs ksh and bash

Here's a simple script that sets up a temp dir in the current dir and a trap to delete it on exit. #filename: script set -x trap 'rm -rf "$d"' exit d=`TMPDIR=$PWD mktemp -d` "$@" If I do ksh ...
0
votes
0answers
45 views

ksh script to ftp file to remote directory script

hello I have this script, basically I need to ftp to remote server only the new files for example that will be generated today or by date, so it does not import the old files, just the new ones I have ...
1
vote
1answer
104 views

Find files older than a given file - a few hours

I'm using the following to find all files that are older than a reference file... find /home/testuser -name "dummyfiles*" ! -newer referencefile.txt ... which works as expected. However, I want to ...
0
votes
2answers
66 views

mv files older than 8 days in ksh script [closed]

need help to create script in KSH to mv files to other directory in same server older than 8 days they all .CSV
1
vote
1answer
83 views

How to count a string occurrence,search in between a pattern for specific string

I am working on a ksh script whose scenario is as follows: I have a text file for students' reports which contains details of students like: Student_1 Name: ABC Class:X Head Teacher:SITA Status: ...
1
vote
1answer
42 views

How to find all the hexadecimal numbers in between 2 numbers

I want to write a little function that would help me determine all the hexadecimal numbers present between 2 numbers. input.txt: 2E25:2E30 Desired output: 2E25 2E26 2E27 2E28 2E29 2E2A 2E2B 2E2C ...
1
vote
1answer
73 views

Catenation of two commands to a file and email output

#!/bin/ksh #HOSTS format: HOSTS="xxxx.xxx.xxx.xx-ACCOUNT" FILE=/home/angela/list.txt #list will be saved on list.txt date > $FILE echo >> $FILE for host in $HOSTS; do ip=$(echo ...
1
vote
2answers
148 views

Compare two times in HH:MM:SS format - ksh

Is it possible to compare two time (24-hour format)? What I need is to just check if the first time is earlier than the second time. Example: $ ./script.ksh 09:30:15 13:00:34 okay $ ./script.ksh ...
0
votes
4answers
948 views

check if date argument is in yyyy-mm-dd format [closed]

Is there a way to check if a date argument is in the correct format (YYYY-MM-DD)? I got this from the web but it doesn't work for me: date "+%Y-%m-%d" -d "2015-10-11" > /dev/null 2>&1 ...
0
votes
4answers
57 views

Use of shift $(($OPTIND -1))

I did see the post Explain shell command shift. As i am unable to comment there i would like to know the use of Shift command. Does it mean that the parameters passed to the script will be empty after ...
2
votes
1answer
109 views

SFTP Dual Factor Authentication

My Issue I am trying to automate a file fetch from an external [SFTP] server. The server is using 2-factor authentication. First, it needs a public-private key pairing established [This has already ...
1
vote
1answer
111 views

How can I see history of the “at” command in AIX?

I'm experiencing a strange problem where occasionally the at command appears to not be running the command I've configured it to run. For example: at -t 201510071042 runsomescript <Ctrl-D> ...
2
votes
1answer
43 views

Shell Script - Redirected output to a file and results are not as expected in first run

I have redirected the output of the command which returns some times 2 rows, 5 rows.. 100 rows etc in the file.. and i will use this file in if condition later to check some other conditions.. ...
1
vote
4answers
45 views

Symlinks according to directory depth

I have the following directory structure that I need to create, and while doing so, I need to also create the zip files which are symlinks. /a/2015-08-17/a.zip /a/2015-08-17/a_b/a_b.zip ...
-1
votes
4answers
232 views

Script to convert a directory of ksh scripts to bash scripts?

Since both ksh and bash are based upon sh many Korn Shell scripts (ksh) will simply run as Bourne-again Shell scripts (bash) once the shebang and file extension are changed, and you call $ bash ...
2
votes
2answers
46 views

ksh if statement syntax

I have this if statement and everytime I change sth another thing seems to be wrong.. Can you see the problem? Thanks! if [[ $(ps -ef | grep "Process" | grep -v "grep" | awk '{print $2}') = '' ]]; ...
2
votes
1answer
111 views

How to get the current date and time in YYYYMMDDHHMMSS format in ksh88?

I am new to Unix and in need of some urgent help. I looked around a lot first to find how to get date difference (in a 1 or 2 liner code). But none worked for me. My requirement is to get difference ...
1
vote
1answer
54 views

Replace or modify file contents at one shot

I have file where I need to modify some lines for every account. The line which I need to modify looks like as below: PstlInfo <some content> NNYYYN (Every account will have this line) the ...
2
votes
1answer
52 views

Script to mail PDF files [closed]

It's a wrong question..please delete itn
2
votes
2answers
238 views

Copying latest modified file from multiple directories

I have directory structure adc/asd/abc.20150918_150635.gz, adc/asd/abc.20150921_140748.gz .... (where .gz file names contain time stamps of its creation). Many other directories similar to asd are ...
4
votes
3answers
47 views

Open a file with line numbers in more (AIX)

How do I open a file in more mode with line numbers. I am using ksh on AIX for less I use -N but for more it is not working. less -N filename
0
votes
2answers
304 views

Database: 0403-009 The specified number is not valid for this command

getting the error as Database: 0403-009 The specified number is not valid for this command. Code:: #!/usr/bin/ksh #set -x WORKFILE="/tmp/oatest.out" DDLFILE="/tmp/oatest.ddl" ...
0
votes
0answers
54 views

Is the pipe overloaded?

I am using a coprocess to run commands in siebel server manager. I am reading commands from a text file (around 2000 commands) and executing them one by one in siebel server manager. After executing ...
0
votes
1answer
64 views

Remote execution of a file is not working

I'm trying to execute a local file (here /tmp/cmd) on a remote machine (slc05bkt) using SSH. Here's the command I'm trying from a script file: cmd="ssh -v ssuthari@slc05bkt \"bash -l -s\" < ...