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
0 votes
2 answers
86 views

How to check the headers between 2 CSV files in unix?

File1 - filename.csv File2 - filename.csv I wanted to compare the headers between these 2 files in linux using a ksh script. case 1:- Say, the header of file1 is INPUT --> NAME,UNIT CODE, VAR ...
Jay's user avatar
  • 1
0 votes
0 answers
28 views

Process substitution, variable substitution and wildcard expansion [duplicate]

I have this code: if (( i == 0 )); then findCommand="find . -name \"${id}*0${month}*\" | sort -r | head -1" else findCommand="find . -...
const314159's user avatar
0 votes
2 answers
40 views

Adding a newline above PS1 that survives prepending

In OBSD ksh, I had a PS1 which prepended a blank line: PS1="\n[\u@\h] \w\n\$" The problem with this was that pyenv prepends the name of a virtual environment when that environment is ...
user1093043's user avatar
-2 votes
1 answer
63 views

"for" loop is not executing on the remote server using SSH

The below "for" loop works locally on the same server. But when triggered through "ssh" protocol on remote servers, the output is not received. Please, can anyone suggest how to ...
ShyamNarayan's user avatar
4 votes
2 answers
416 views

Why does ksh93 not support the %T format specifier of its built-in printf in AIX?

We have tested the following commands with ksh93 printf in many AIX 5.3/6.1 systems, but they all failed with the same result. Why is that? # # oslevel -s 6100-07-09-...
lylklb's user avatar
  • 193
0 votes
1 answer
55 views

Is KornShell pattern a regular expression?

KornShell pattern extends POSIX shell "glob" patterns (i.e. *, ?, etc.) with repetition specifiers such as *(...), +(...), as well as negation among many nice features. In a hobbist project, ...
DannyNiu's user avatar
  • 622
0 votes
2 answers
132 views

Bash and other shells $(...) remove the ending newline character [duplicate]

Why the shell structure $(...) removes the ending newline character? #!/bin/bash S='a b ' printf '%i [%s]\n' "${#S}" "$S" T=$(printf '%s' "$S") printf '%i [%s]\n' "...
Olivier Pirson's user avatar
2 votes
1 answer
101 views

if var='value' then in Zsh: Is it really a valid syntax without semicolon?

The following code works on Zsh 5.8 that I tried, despite the missing semicolon. But is it really a valid Zsh syntax? #!/bin/zsh if var='value' then echo 'then' fi Without an assignation that ...
Olivier Pirson's user avatar
1 vote
3 answers
77 views

ksh parameter expansion: replace / with -

Say I have this: str="@test/string" echo $str @test/string echo ${str#@} test/string works as expected, but echo ${str//\//-} ksh: ${str//\//-}: bad substitution fails. (expected @test-...
Lee's user avatar
  • 491
1 vote
1 answer
161 views

OpenBSD: npm install sodium-native, interpret error messages

I am attempting to install sodium native as an npm package on OpenBSD 7.3 amd64. Aside: As a dependency of Hypercore, Hyperbee and Corestore. This needs node-gyp. Following this, I set the C and C++ ...
Lee's user avatar
  • 491
0 votes
1 answer
77 views

Writing a ksh-script with a predefined time-out

My OS is AIX (7.2) and my shell is ksh88 (preferably) or ksh93, if necessary. I want to write a script that sets some maximum timer for its execution. If it manages to finish its task within this time ...
bakunin's user avatar
  • 475
0 votes
0 answers
86 views

Having problem using uuencode in script

I am using below command and it works: uuencode stats.txt stats.txt | mailx -s "users" [email protected] But when I put same command inside my shell script, it does not work. I dont have email. ...
Drsin's user avatar
  • 1
0 votes
0 answers
51 views

ksh script can I execute function from different user

I am wondering I can execute or call the function from different user? I am running below command from root, but I want to switch to different userid to execute the function. dbpath() { command 1 ...
user3590915's user avatar
0 votes
1 answer
179 views

Switch user using EOF does not work su - ${instance} <<'EOF'

I am running a ksh script from root where I switch (su) to different users and execute the commands. But, some reason EOF does not. Here is part of my code. This part of the code does not work su - $...
user3590915's user avatar
1 vote
1 answer
57 views

Why does enclosing a command in double quotes affect aliases?

I have an alias rm='/bin/rm -i' and I know that if I type "rm" filename in the command line, the alias will be ignored somehow and the normal rm command without the -i flag will be called, ...
BrassPandaSax's user avatar
3 votes
1 answer
396 views

Why is "${1-"$var"}" (option 6 down below) not mentioned in POSIX?

The only reference I could find in the spec is this: It would be desirable to include the statement "The characters from an enclosed "${" to the matching '}' shall not be affected by ...
QuartzCristal's user avatar
0 votes
1 answer
79 views

Issue - infinite loop using while on ksh script

I'm writting a scsript to automate some check at work & i have trouble on only 1 standing issue which is the script never ending. It do the all task over & over. There are 2 while loop & ...
shuratenko's user avatar
5 votes
3 answers
4k views

convert file to utf-8 based on the file command

Have an upload process, reads the file and using sqlldr it uploads the data to DB. I was getting invalid number issue while processing the file in sqlldr. Found the file is in UTF-16 format and then ...
Pat's user avatar
  • 229
42 votes
1 answer
6k views

What's wrong with var=$(</dev/stdin) to read stdin into a variable?

We've seen a few posts here lately that use this: var=$(</dev/stdin) in an attempt to read the shell's standard input into a variable. That is however not the correct way to do it on Linux-based ...
Stéphane Chazelas's user avatar
-3 votes
2 answers
191 views

I'm using bash on Debian 11. But how may I open a Bourne, Korn or C-Shell if I am willing to?

I am reading a book speaking about Bourne Shell (the ancestor of bash = Bourne-Again Shell I'm currently using), Korn Shell and C-Shell. I was curious, and willing to experience them. On a bash ...
Marc Le Bihan's user avatar
-3 votes
1 answer
324 views

Awk variable passing error

Below works fine: awk '{print $1,$2,$3,$4,$5,$6,$7,$8,$57,$9,$55,$10,$11,$12,$56,$13,$53,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25,$26,$27,$28,$29,$30,$31,$32,$33,$34,$35,$36,$37,$38,$39,$40,$41,...
Ami's user avatar
  • 1
0 votes
1 answer
171 views

how to check for specific string in a file named abc.txt and write that missing string to another file (xyz.txt) using a shell script?

For example, generally I need to check for 5 strings. (Note : the strings are in file format .txt) file1.txt file2.txt file3.txt file4.txt file5.txt but there are 3 strings in abc.txt file1.txt ...
Jayashree's user avatar
0 votes
0 answers
60 views

filewatcher script in ksh script

I wanted to edit a already created filewatcher script with the given logic the source file path is stage path (stage/filewatcherwrap.ksh) there are 4 files in the below given format in stage path ...
Jayashree's user avatar
0 votes
1 answer
56 views

set -o vi in prompt leaves insert mode every time I use arrow keys and has warning bell constantly (bash/ksh)

I might use arrow keys to go back and edit a flag when typing a command in my prompt and doing so constantly kicks me back from insert mode to normal mode. How do I turn this off so it matches the ...
guest's user avatar
  • 77
1 vote
1 answer
104 views

Confused why pgrep can't show children of jobs started in subshell

I need to use korn shell for a script I'm writing and ran into issues managing nested child processes. The example code below demonstrates my issue. In it I create a temporary file for x seconds, then ...
guest's user avatar
  • 77
1 vote
1 answer
227 views

Read content of file in ksh and split it by ','

My file.txt contains the following content:- ./raw_input/0009/img.raw,./raw_input/0009/calib.raw
Bhawneet Singh's user avatar
0 votes
0 answers
49 views

Korn shell (ksh) omits closing quote when displaying aliases

When displaying aliases in Korn shell (ksh) the closing quote is omitted. This happens with both predefined and user-defined aliases: >> alias type r l ltr type='whence -v r='hist -s l='pwd; ls ...
KS_on_StackExchange's user avatar
0 votes
3 answers
821 views

Concatenate files with same structure, keeping header only for 1st file

I want to merge 28 files with different names and the same data structure, using the script below: $ cp mohan.csv Consolidate.csv $ for fname in line do cat $fname | sed '1d' >> ...
Mohan Babu's user avatar
1 vote
1 answer
2k views

Call a command from a shell script, passing most arguments, allowing arguments with blanks

I am have a wrapper run_sas.sh around a command sas that runs SAS code in batch. A typical call looks like this ./run_sas.sh -sysin /my_code/my_program.sas -log /my_log_folder/my_program.log run_sas....
Dirk Horsten's user avatar
-1 votes
1 answer
353 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
ssaf's user avatar
  • 1
0 votes
5 answers
940 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 ...
ayrton_senna's user avatar
  • 1,021
0 votes
3 answers
633 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 ...
Nainita's user avatar
  • 2,732
0 votes
0 answers
135 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 ...
guest's user avatar
  • 77
1 vote
1 answer
617 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 ...
guest's user avatar
  • 77
2 votes
0 answers
108 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 ...
Kajukenbo's user avatar
  • 187
1 vote
1 answer
307 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 ...
Rafiki's user avatar
  • 111
0 votes
2 answers
353 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 ...
Mineralwasser's user avatar
1 vote
2 answers
3k 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 ...
Scouse_s's user avatar
0 votes
3 answers
37 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|...
shaik's user avatar
  • 1
1 vote
1 answer
456 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 ...
Paul's user avatar
  • 507
0 votes
1 answer
322 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 ...
Pat's user avatar
  • 229
4 votes
1 answer
580 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 ...
Pat's user avatar
  • 229
2 votes
2 answers
2k 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....
defekas17's user avatar
0 votes
1 answer
270 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 ...
Hugobop's user avatar
0 votes
1 answer
323 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, ...
Hugobop's user avatar
0 votes
1 answer
264 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 ...
Data girl's user avatar
0 votes
1 answer
71 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'...
Mauricio Reyes's user avatar
0 votes
0 answers
33 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 ...
Michele's user avatar
  • 103
2 votes
0 answers
76 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 ...
Martin's user avatar
  • 21
2 votes
1 answer
267 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" ...
andreoss's user avatar
  • 406

1
2 3 4 5
17