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 votes
1 answer
38 views

One master ksh file to call 2 ksh script files [duplicate]

I have 2 ksh (korn shell script) : file1.ksh and file2.ksh; and I want to have a master file ksh script that will call the 2 files; what's the code I have to put in my master file? Thanks
user avatar
  • 1
0 votes
6 answers
83 views

How to ignore all text containing special character more than once?

Sample Input: apple_ig rabbit_cat_ig dog_ig bird_duck_ig orange_ig goat_ig Expected output: apple_ig dog_ig orange_ig goat_ig I need to ignore all data that contains underscore _ more than once in ...
user avatar
0 votes
3 answers
76 views

Script to keep the latest 5 files and rest will be moved to other destination

Source path: /var/log/ Here I have 4 folders named ad1nrld,ad2nrld,icp1rmnrl,icp2rmnrl I can move all the files to the other destination named /home/spsy/logs_bkp. But I want to keep latest 5 files in ...
user avatar
  • 2,386
0 votes
0 answers
32 views

How to keep track of PID of multiple active scripts that spawn multiple bacground processes

I have some programs that that need to run in order with a common task between each program that modifies the data and sends it to another location for processing. each modify_data script spawns ...
user avatar
  • 25
1 vote
1 answer
101 views

grep with many patterns from file and show which pattern matched which file without rereading files

I have n separate non fixed greps against m files. I only need to know if there is at least 1 match in each file, but I need this for each pattern. I currently make n separate greps so I can merge ...
user avatar
  • 25
2 votes
0 answers
30 views

How to start xterm instance which automatically opens nvi in a "complete" environment with ^Z :suspend capability

I am having problems starting a xterm instance that automatically opens nvi in a "complete" environment with job control. I am referring to xterm specifically here and not a VTE skin or ...
user avatar
  • 101
1 vote
1 answer
75 views

Display branch name in $PS1 on ksh88

I want to display my current git branch in the prompt in ksh88. I'm working on a legacy project, when the backend run on IBM's AIX, with a mandatory ksh88 shell. I can switch to say, bash, for some ...
user avatar
  • 111
0 votes
2 answers
56 views

ksh on AIX - pwd in prompt does not update when changing folders

I'm very new to AIX as well as ksh, but I currently have some downtime at work and am trying to configure my prompt to be both colored and show my current location. At the moment, I get the correct ...
user avatar
1 vote
2 answers
260 views

How can I append new lines in a CSV file and modify them in Unix

I am new to Unix in general and starting to learn shell scripting. I am working with a CSV file with the below sample rows (it's a large CSV file with 4 entries for each item): Table 1 Item ID Time ...
user avatar
0 votes
3 answers
30 views

How to nullify multiple columns at specific positions?

Input- FN|LN|ADD|STATE|PIN|CONT|GRP|PCN|BIN|TOKEN72|TOKEN73|TOKEN74|TOKEN75|ndc|ncpdpd FN1|LN1|ADD1|STATE1|PIN1|CONT1|GRP1|PCN1|BIN1|TOKEN721|TOKEN731|TOKEN741|TOKEN751|ndc1|ncpdpd1 FN2|LN2|ADD2|...
user avatar
  • 1
0 votes
0 answers
32 views

djvu file renaming based on metadata tags

I have a disk of engineering drawings and manuals in .djvu format. Unfortunately each file is named a0001.djvu, a00002.djvu. There are several thousand of these and I'd like to rename them based on ...
user avatar
1 vote
1 answer
88 views

Why doesn't the terminal window title change when logging into OpenBSD from Linux Mint?

From a Linux Mint terminal window, when I ssh into OpenBSD, the terminal window title remains the same as just the terminal username@localhostname:~, whereas logging into Ubuntu the terminal window ...
user avatar
  • 423
0 votes
1 answer
55 views

Read first line split based on delimiter and store it in array (in ksh)

I am reading the first line of the file, header row, split by delimiter | and assigning it to array. IFS='|' read -r -a header < "/file_uploads/file_headers.txt" This is working fine in ...
user avatar
  • 155
4 votes
1 answer
215 views

bash replacing special characters in a variable

pipe (|) limited text file is transferred from Windows application for processing. While processing there is a special character in the first column in first line of the file. This is how file looks ...
user avatar
  • 155
2 votes
2 answers
270 views

How to store query multiple result in shell script variable(Array)?

I'm trying to do a query and store every row result in an array element in ksh (maybe bash). I do: result=($($PATH_UTI/querysh " set heading off set feedback off SELECT columnA,columnb FROM user....
user avatar
0 votes
1 answer
35 views

Allow user to run nonpermissive commands in shell script (KSH)

I have a ksh script I am developing for work. (I am on the newer side to shell-scripting) I have root access but the future-users of this script will not. Say the other user is named User1. Within the ...
user avatar
0 votes
1 answer
77 views

Find and manipulate array element in KSH

I have an array that reads like this: # echo "${ARRAY[@]}" 1=Napp Slice 4=NNN Issue 3=GG Allow 2=CO-OP 1=Quit And I want to loop through it to see if any contain the word Quit and if so, ...
user avatar
0 votes
1 answer
73 views

Missing operator issue

I was trying to do an OR logic in If condition condition 1 => warning ="" and err_code !=1 OR condition 2 => threshold =1 and threshold_load_ind=Y and err_code!=1 This is throwing an ...
user avatar
0 votes
1 answer
65 views

'If' statement breaking his own rule or I'm doing so

Explanation: I'm playing a little bit with a script this one helps notifying to user about SSL certificate expiration. If certificate has less than 30 days to expires, this will notify to user, if isn'...
user avatar
0 votes
0 answers
22 views

korn script printing garbage for param sent to function in utils file

I have a korn util script that isn't receiving correct parameters. I'm not sure why. I'm new to korn, and searching for the issue online didn't help. I execute the calling script this way from ...
user avatar
  • 103
2 votes
0 answers
40 views

Problem with ksh namespaces defined inside functions

I'm new to ksh namespaces. The problem I'm seeing is that if I define a namespace inside a function, then variables defined within that namespace clobber the same-named variables outside the namespace ...
user avatar
  • 21
3 votes
1 answer
168 views

OpenBSD's sh: shebang is not being used

I have three scripts, two of them are used as a shebang shebang-1 #!/bin/sh echo "#1" exec sh -- "$@" shebang-2 which uses shebang-1 #!/home/a/ex/shebang-1 echo "#2" ...
user avatar
  • 330
0 votes
1 answer
25 views

My calculation is getting converted to integer by default(KSH) [duplicate]

I am assigning a decimal value to a variable which is an output from an oracle command. when I echo the variable I see the decimal value. For example, echo $a is showing me .7214 but when I do ...
user avatar
  • 1
0 votes
1 answer
77 views

Using Heredoc with command substitution referring to the shell PID differs between ksh and bash

Korn script: #!/bin/ksh sqlplus -s / << EOF define a=$(pgrep -P $$) define a !ptree &a EOF VS Bash script: #!/bin/bash sqlplus -s / << EOF define a=$(pgrep -P $$) define a !ptree &...
user avatar
  • 3
0 votes
1 answer
31 views

Error in script to check(or wait) for availability of file in directory

I want to write a shell script that checks if trigger file is available in my directory or not. If not available I want the code to wait for, say 1 hour, and check again for availability until found. ...
user avatar
0 votes
1 answer
72 views

in AIX ksh the command "mail" reads from STDIN and stops a loop wherein it is

using ksh on an AIX 7.2 system I have the following inputfile: line1 line2 line3 I have the following code (rather simplified) cat infile | while read strA ; do echo "strA: $strA"...
user avatar
  • 1
-1 votes
3 answers
92 views

Finding element of file in KSH

please help me figure out what I am doing wrong. I have this file called "res.xml" <sequence type="a"> <transaction> <branchSerial>1</branchSerial> &...
user avatar
0 votes
1 answer
103 views

Migrating from AIX to RHEL

I am moving a server from AIX to RHEL, which means running my application shell scripts into the RHEL server. Scripts have .ksh extension In our AIX server, default shell is KSH of course, shebang ...
user avatar
1 vote
1 answer
686 views

What repository provides ksh for RedHat universal base image version 8 (ubi8)

Please tell me if RedHat provides a repo with the ksh RPM for their Universal Base Image version 8 (ubi8). The UBI images are great because they are pre-configured to fetch RPMs from many repos but ...
user avatar
0 votes
0 answers
37 views

Ksh script issue

script: rec_len=`awk -v l="$col_rec_len" -v count=0 '{if(length($0)!=l) {printf "%s:%s:%s:%s\n", FILENAME, FNR,length($0), $0 >> "/dev/stderr" ...
user avatar
0 votes
2 answers
111 views

ksh SET -A array read issue

hello i was trying to read a line to array using ksh script . But some of its values are stored multiple times in adjacent array elements when there is a comma in the field value. How can this is ...
user avatar
0 votes
0 answers
86 views

How to write .csv from another .csv in Bash or Ksh

I have a lot of output's from my matlab in .csv. I would like to put them together in one output.csv file. So my idea was use my .csv created by Matlab as variables for my output.csv global. #!/bin/...
user avatar
3 votes
1 answer
279 views

Bash Script : Problem with variables from csv file

I'm having a little problem getting variables from a csv file on my Linux machine and using them in an if. I have the following csv: Name;Age Marc;18 Joseph;10 I'm trying to get this information from ...
user avatar
3 votes
1 answer
129 views

Why can I suddenly not access my command line history?

I use ksh (version: sh (AT&T Research) 2020.0.0) on Ubuntu 20.04, and I use vi command line editing mode (set -o vi). This has worked fine for years, but recently I have noticed some oddities, and ...
user avatar
  • 335
1 vote
0 answers
109 views

Not able to run a nohup script inside a ksh

I'm trying to read a text file (containing set of instructions) #!/bin/ksh INPUT=input.txt OLDIFS=$IFS while IFS='~' read -r ACTIVE process_name PATH STOP START DB do if [ $ACTIVE == 'Y' ]; ...
user avatar
  • 11
6 votes
3 answers
183 views

Is there any reason to avoid sourcing the shell's configuration file?

I recently read an answer here that included the following advice: However, as a rule, ⚠️you should not source ~/.zshrc. Depending on what's in your dotfiles, this can lead to all sorts of problems. ...
user avatar
  • 215k
0 votes
1 answer
30 views

How can I get first day of the month, 10 minutes after midnight using date function(ksh)

Basically title. I need to execute a script that will launch once a month without using crontab. Launching of the script is done in another script that executes every 5 minutes. So my current solution ...
user avatar
-1 votes
0 answers
104 views

How to prevent ksh from truncating lines in interachive shell?

How do I avoid truncating lines in interactive shell? Whenever the terminal window resizes, the command I type gets truncated and a '<' shows at the end. I'm using pdksh(default shell of openbsd) ...
user avatar
  • 1
1 vote
1 answer
293 views

Change shell from bash to ksh permanently with no admin rights

I need to change my PuTTY shell from bash to ksh permanently. The chsh command and editing /etc/passwd are not available to me as I don't have admin rights. Please help me understand what needs to be ...
user avatar
  • 13
0 votes
1 answer
150 views

Migrate shells Solaris ksh to Red Hat

We have hundreds of shell scripts running on a Solaris 11.3 server. System shell is ksh93 $ ls -l /bin/sh lrwxrwxrwx 1 root root 13 Apr 12 2018 /bin/sh -> sparcv9/ksh93 All the ...
user avatar
2 votes
1 answer
190 views

How can I redirect all output of a script to a file and replace passwords?

I'm running a ksh script on AIX 7.2. In debug mode I want to redirect all the script does to a brkpt-file. The script also makes logins to another application and therefore uses a password (let's say &...
user avatar
  • 23
0 votes
0 answers
71 views

It is not possible to unset IFS in ksh93. Is it documented?

In ksh93 it is possible to unset any variable like so: $ var=value; echo "$<${var+set}" <set> $ unset var; echo "<${var+set}>" <> However, IFS doesn't work ...
user avatar
  • 38.8k
1 vote
1 answer
219 views

Shell Parameter expansion not working in AIX

I'm trying to substitute a specific string that isn't working in AIX but when I run it on RHEL I'm able to get the expected output. Here's the command: filename=25_032021_abcdefghijklmn.txt; mv /u/foo/...
user avatar
  • 13
2 votes
1 answer
287 views

SFTP - download different types of files using mget

I want to download only specific files from a server which could have other files too. So I am using the below mget commands. But if PO*.txt don't exist, it exits and doesn't continue to get INV*....
user avatar
1 vote
2 answers
77 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 ...
user avatar
  • 15
2 votes
2 answers
323 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 ...
user avatar
17 votes
1 answer
893 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 ...
user avatar
0 votes
1 answer
95 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 ...
user avatar
  • 61
-3 votes
1 answer
39 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/...
user avatar
0 votes
1 answer
22 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 & ...
user avatar

1
2 3 4 5
16