Questions tagged [ksh]

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.

Filter by
Sorted by
Tagged with
1
vote
2answers
60 views

ksh88 AIX merge two files based on partial string match in one column

Using ksh88 on AIX machine, I've tried a whole slew of things that are ultimately not working. File_A has 2 columns without headers: the user group that created the directory in column 1, and the full ...
0
votes
0answers
14 views

Linux KSH shell history - command still goes in history file after issuing unset history

I want to issue command, with pre-requisite that it should not get logged into history of Linux. I dont want to SET any env variable at system end. For bash, sh, tcsh, csh shell when we execute unset ...
2
votes
2answers
36 views

How can I sort with the timestamp in the filename

I have a list of files in the directory having different time stamps as part of the file names. I want to sort the files based on the timestamp on the filename. (I do not want to sort based on the ...
16
votes
1answer
493 views

How to use associative arrays safely inside arithmetic expressions?

A few Bourne-like shells support associative arrays: ksh93 (since 1993), zsh (since 1998), bash (since 2009), though with some differences in behaviour between the 3. A common use is for counting ...
0
votes
1answer
22 views

ksh break and continue based on values

I amrunning below script in KSH shell. I want to run the loop for 6 times to call Java program and in betwen if there is no exception found , then it should return =0. if in all the 6 iteration, we ...
-3
votes
1answer
35 views

I am getting an error ./test1hc.sh[59]: [[[: not found in if condition while executing the below shell script

exec > /apps/jobs/logs/healthcheck.log 2>&1 set -x #!/bin/ksh . ~/vdom.profile db2 CONNECT to $DATABASE_MIF user $DBUSER_MIF using $DBPASS_MIF rm -r /apps/jobs/scripts/alerts/...
0
votes
1answer
17 views

case while option not showing last argument in shell script

Shell script is not showing last value in getopts using while command. See below command and code and output command: nohup ksh newtome.ksh -m 100 -l LSD -t 10202020 -p ABC,CDE > log.txt & ...
1
vote
1answer
56 views

add characters at end of each record in a csv file that contains return characters in fields

I have a csv file with 5 columns in it of varying length. The delimiter between columns is "," and the last column ends with ". The row delimiter is a newline. The latest file has ...
0
votes
1answer
63 views

To display the total number of records minus one in a file in UNIX script passes as parameter

The input is provided in the following format: ksh -x count.sh filename `cat filepath/filename | wc -l Here the problem is that I need to pass the second parameter cat to another variable and to do ...
2
votes
4answers
114 views

What shells support “value substitution” like MirBSD Korn Shell?

On Android (which uses mksh, MirBSD Korn Shell), there's a special syntax of string substitution (called "value substitution"): ${|commands} Instead of collecting output of the commands (as ...
0
votes
1answer
53 views

Is there a way to copy the command history files written & copied simultaneously twice?

This is regarding the ksh shell running on both Linux and AIX machines. Is there a way to copy the command history files written & copied simultaneously twice (shell doesn't allow HISTSIZE to be ...
0
votes
0answers
22 views

how to get exitcode of child process in order of completion

I have 10 child process running in parallel, my 2nd child process is taking time meanwhile my 3-10 child process are completed . as of now my logic is wait $pids[@] return[$pids[@]=$? # pids is any ...
1
vote
2answers
47 views

Varibles - Union [duplicate]

FICH10=primero.sh FICH20=segundo.sh for i in 10 20 do echo $FICH($i) # I want resolved first $i and then resolver var FICH10 done I want it to first solve $i and concatenate it to the FICH ...
0
votes
0answers
25 views

How to launch this DtKsh application?

I'm working with Desktop Korn Shell You can create examples like this one; So I want to create it and here's the code of this: #!/usr/dt/bin/dtksh ##...
0
votes
0answers
19 views

DtKsh related with Bad Interpreter issue

I want to create a Hello World exmaplo in CDE, as KSH scripting like this and this I've started on this at my job; there are computers with AIX, so I tested the previous examples successfully. Then I ...
4
votes
0answers
63 views

${$} working fine in ksh93 but ${$} not working when I use in cat << EOF

I'm executing this in the ksh93 shell. If I use normally like ~# echo ${$} 1295 but using ${$} in a here-document is not working: ~#cat <<EOF ~#> ${$} ~#> EOF syntax error: `$' unexpected ...
-1
votes
1answer
34 views

Run scripts in parallel, one set after another splitting main file?

I have a file, abc.txt, like this on a Linux machine: abc|yes|50c|1|pending bcd|no|100c|1|pending cde|yes|45c|2|pending def|no|44c|2|pending I have split this file into two files based on the 4th ...
0
votes
1answer
37 views

how can i run script paralley with diff arguments taking input from file

I have a file, abc.txt, like this on a Linux machine: abc|yes|50c|1|pending bcd|no|100c|2|pending cde|yes|45c|3|pending def|no|44c|3|pending I have to call a script1.ksh with the 3rd field as a ...
1
vote
1answer
265 views

How to solve 'newline' unexpected in KSH?

I'm getting starting with GUIs in KSH, so this is my first example: #! /usr/dt/bin/dtksh main() { XtInitialize TOPLEVEL dtHello DtHello "$@" XmCreateMessageDialog HELLO $...
1
vote
1answer
59 views

Conditional regex pattern matching in a korn shell script

I have started learning Unix shell scripting using korn shell. Please enlighten me finding the mistake I am doing while writing a ksh code for below a problem as stated below : My script takes 2 ...
1
vote
1answer
72 views

How to join results of two commands in IBM AIX ksh

I would like to perform script below but without creation of intermediate files (lsfs.out, df.out) on IBM AIX with ksh lsfs_out=`lsfs | sed -n '1d;p' | sort -b -k 3` df_out=`df -k | sed -n '1d;p' | ...
-1
votes
3answers
71 views

Parse tabulated key-value pairs to set shell variables

I have the following table: san0 san1 san2 san3 san4 san5 san6 san7 6.36% 6.24% 6.24% 6.24% 6.33% 6.25% 6.25% 6.25% I need to parse this table to import the values ...
0
votes
1answer
56 views

Converting loop into a single line command to improve shell script performance in HP-UX

I have the following loop in my shell script. What it does is it removed the record which is more then 3000 bytes actually it taking longer time as it read and line by line check byte, and if less ...
0
votes
1answer
32 views

How to find where ksh setup aliases?

Where ksh can load aliases from? Checked /etc/profile, ~/.profile - nothing There is no ~/.kshrc. Tried: $ grep -r 'alias BADALIAS' /etc - also nothing
-1
votes
2answers
124 views

Convert array into string

I have a string say, test_var=ab_c_de_fg_.txt. I need to store ab_c in one variable (characters before the 2nd _) and de_fg_ in a second variable (characters after the second _ and before .txt), so ...
0
votes
1answer
228 views

Sed substitution with quoted variable Unix KSH

I'm trying to replace the LIBNAME statements in a SAS program. An example of a line that I would want to modify is: LIBNAME somelib '/random/path/reference/'; I want to leave the somelib string ...
1
vote
1answer
78 views

UNIX KSH - Using double quotes or no quotes when assigning strings with wildcard to a variable?

I am new to UNIX and currently working on a shell script where I will be receiving files with names such as abc_123_date.zip so the file names will be abc_123_12312005. Instead of hardcoding abc_123_*....
2
votes
1answer
101 views

1-liner process substitution for ksh

I have this command, which works fine for bash: sh <(curl -sSl https://appi.sh/launch) (launches this interactive script) I'd like to get this 1-liner working for ksh, too. Currently, it errors ...
0
votes
2answers
30 views

Move files with certain suffix to a directory

Hi I have the below lines in my .ksh script: for file in $fileDirectory/*.$yesterdayDate do mv *.$yesterdayDate "$fileDirectory/$yesterdayDate" done However, when I execute this I get the following ...
0
votes
0answers
20 views

Running commands remotely and script not exiting on error

I have a simple script which takes the first argument as a hostname and tries to connect to it and run some commands then saves the output locally. But whenever I pass an invalid hostname and it ...
0
votes
0answers
37 views

Rotate file name in script on the 1st of every month

I have a script that runs every 5 minutes in the crontab and writes output to the same file. I want to move this file and append the date for the month on the 1st. So far I have this logic in place: ...
1
vote
0answers
40 views

Is there a nullglob option for ksh(korn shell)? [duplicate]

I want to run a for loop, is there a way to do a nullglob in the korn shell like in other shells? for file in docs*.txt; do
0
votes
0answers
78 views

How to auto prompt enter key with yes no thereafter in script ksh

I have a command within a script that prompts a user to hit enter key 1st with yes no thereafter. Creating a basic script to auto answer yes no questions is not a problem. I am finding it difficult to ...
-1
votes
2answers
136 views

How to compare string to a wild card string in shell script?

I want to compare file name string with file mask in a ksh shell script. Can you please correct the syntax? if [ "NPER20200422TEST.PTN" = "NPER*.PTN" ] then echo "File matched" else echo "File not ...
2
votes
1answer
5k views

set -eo pipefail differs on ksh and bash

I would like like to terminate a script on any failure including inside a pipe. In bash, you can set -eo pipefail, but this doesn't work in ksh. Example: # x set -eo pipefail false | true echo "done:...
0
votes
0answers
13 views

Comapring variable in realtime in KSH on oracle database using loop

These are the variables, which I need to loop until they are equal and then end followed by the next set of instructions. None of the below-mentioned loops are functioning as expected. I expect the ...
0
votes
2answers
347 views

Compare two files based on key, print difference in value in another file in Bash Shell Script

Need help on shell script, I have 2 large files around 1.2 GB data, with key and values, I need to compare both files based on the key and store difference in the value in the third file and the ...
0
votes
0answers
12 views

YAML-like anchors/aliases in KornShell

I have a generic YAML to KAML (KornShell) converter based on libYAML which is missing support for YAML anchors and aliases. Implementation of aliases for scalar values is quite trivial in that ...
19
votes
4answers
2k views

Preferred syntax for two lines long pipe [closed]

When writing a long pipe it is usually clearer to separate it in two lines. This long command line: ruby -run -e httpd -- -p 5000 . 2>&1 | tee >(grep -Fq 'WEBrick::HTTPServer#start' &&...
0
votes
2answers
142 views

Does Korn shell have an equivalent feature to Bash's command_not_found_handle?

And does Korn shell have an equivalent to PROMPT_COMMAND? In Bash, I'm able to make function calls with a parameter when a single input word matches a regular expression. Can Korn shell do this? Let'...
0
votes
2answers
110 views

extract day of the month and hour of a given date format shell scripting [duplicate]

I am writing a script where I am looking for help. I am using date format in my script as below (YYYY MM DD HH MM): $ echo $DT 202002252216 Now my requirement is to compare two dates listed in the ...
0
votes
2answers
562 views

What does this part mean in find command with -exec \{\}? [duplicate]

I have this command (KSH) find <path> -regextype posix-extended -type f -regex '.*/txt' -exec ls -l --full-time \{\} \; | sort -bnr So, I'm reading and deciphering the command above so far ...
2
votes
2answers
3k views

How to add subject to sendmail function

I have the below line code in ksh: echo -e "$SUBJECT"|/usr/sbin/sendmail -f XXXXXX@gmail.com -t XXXXXX@gmail.com but I'm still getting the $SUBJECT in the body, and not as the real subject. what's ...
0
votes
1answer
73 views

krb command not working in ksh script

On a RedHat 7, when I run the following command to get a Kerberos ticket: krb my_user It sends back : Ticket for 'my_user' is valid until 08:36 (28/01) Now I need to run this command from a script....
0
votes
0answers
37 views

How to add in if-clause in KSH?

How do I use "AND" conditioning in the if-clause? The below part isn't working....... I refer to some of the posts and some show that it needs double brackets....But I tried with while-loop, one ...
0
votes
0answers
45 views

execute a ksh file from any directory

I have a tom.ksh where it contains #!/bin/ksh . ./tom.ksh print "Check" It ought to print check when executed from any directory ./tom.ksh pop[passing argument] am I right?
0
votes
0answers
37 views

How to pass a folder as argument to the executing script? [duplicate]

I would like to execute a script(h.ksh) with the passing argument kim (which is a folder), so when I run the command h.ksh kim the folder "kim" will be used as a variable in the h.ksh Do I need ...
0
votes
2answers
78 views

how to catch response from server ping and sent alert

I have the below command I'm running: ping ldap.corp.XXXXX.com LDAP Server up: Pinging ldapeu.corp.XXXXX.com [XX.XXX.XXX.XX] with 32 bytes of data: Reply from XX.XXX.XXX.XX: bytes=32 time<1ms ...
0
votes
5answers
65 views

Awk all lines above matched parameter

I have a file called test.out with the below lines in: -rw-rw---- 1 informix informix 9117025 Jan 21 05:22 shop4_0_Log0000331875.Z -rw-rw---- 1 informix informix 8897981 Jan 21 05:24 ...
2
votes
1answer
135 views

How to create sub-directories without HTTP or HTTPS from string parameter

I have ksh script, which is running the below command: mkdir -p down/$JENKINS_URL the thing is that some $JENKINS_URL (string) includes HTTP:// and in some HTTPS://, which is causing the creation of ...

1
2 3 4 5
15