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.
835 questions
1
vote
2
answers
128
views
How to pass an argument by reference to a function in KornShell (PDKSH 5.2.14)
In bash I can use
local -n ref_name=$1
to pass an argument to a function by reference, but the same syntax in ksh throws an error saying
typeset: -n: unknown option
I tried nameref ref_name=$1 ...
1
vote
1
answer
80
views
List all the directories residing in a directory path using KornShell
I have the below shell script which works fine in Bash to list all the directories residing inside a given directory path and add them to an array. But the same script code doesn't work in KornShell.
...
8
votes
1
answer
317
views
bash or ksh 'vi' mode - How to jump to end of history (most recent command)?
I am a long time ksh user, and use bash under duress - both in 'vi' editing mode.
One thing that has always niggled - after searching back through history for a command (.e.g <Esc>/needle), how ...
0
votes
1
answer
70
views
ksh: how to capture the current invoked command and arguments?
How do I obtain a variable with the current command and arguments? I would like to use escape code to print this in an Xterm title bar.
I see Terminal.app on MacOS is determining the name of the ...
0
votes
0
answers
52
views
Shell: redirecting output to /dev/tty and another file in a script? Not having to retype ending?
How do I accomplish this command to redirect command output to multiple files, without retyping the later A=1>&/dev/tty 1>&${TMP}/lastcmdout every time?
I want to see output on the ...
-5
votes
1
answer
78
views
how to check if a large script is only using full paths for the used cmd inside it?
to make a script more secure, we would need to confirm that used cmds, eg.: "/usr/bin/chown" instead of just "chown".
0
votes
1
answer
63
views
xutils.sh in open sourced CDE?
I am reading a book about dtksh.
The first "hello world" example begins as follows:
#!/usr/local/dt/bin/dtksh
. $UTILDIR/xutil.sh
XUinitialize TOPLEVEL Hello "$@"
XUlabel LABEL $...
3
votes
2
answers
121
views
Simulated Execution of Redirections
My shell is the Korn Shell, but I think the problem (and its eventual remedy) applies to other shells as well.
I usually build a "simulation mode" into my scripts to test potentially ...
0
votes
0
answers
63
views
When i trying to execute shell script , it does out come out. keep on running
File name: /u02/app/scmdw/scr/appcheck1.sql
Shell script: test.ksh
#!/bin/ksh
line=`sqlplus $SCMDWSA @/u02/app/scmdw/scr/appcheck.sql`
echo "== Result of SQL: line = $line"
When I try to ...
0
votes
3
answers
241
views
Find command slow when I'm not piping into awk
I have a script I've used for many years for building a list to some directories, with the following lines:
##Find all scenarios for this sector number
find /gsgt/source/scenarios/AT_* -name ${...
0
votes
0
answers
86
views
Concatenating 2 environmental variables in a ksh script [duplicate]
I have a storage.src file with the following 2 environmental variables exported
export FIRST="HelloHelloHello"
export SECOND="World"
I have a .sh file as follows
#!/bin/ksh
. /...
0
votes
1
answer
136
views
Bash Shebang scripts with a .ksh extention
I have inherited shell scripts that have a bash shebang...but for some reason have a .ksh extension.
The creator of these scripts is no longer here and I cant find any reason in Google.
Why would he ...
-2
votes
1
answer
181
views
Assign multiline string to variable in script [duplicate]
I want a variable, let’s say PS, defined in my .profile file with the following value:
PS1='PWD: ${PWD}
$ '
So that when I enter $PS in my terminal, I get a two-lined prompt string, the first line ...
3
votes
1
answer
115
views
How does my function break `functions`?
I wrote a ksh function for git checkout (I've removed some irrelevant proprietary components for the sake of the public question, if you're wondering why it's useful to me):
# Checkout quicker
...
0
votes
1
answer
116
views
ksh88 string substitution in alias | mpv streaming [duplicate]
tl;dr how can I substitute a string (i.e. a youtube/streaming url) in an alias such as alias mpvyt='yt-dlp <URL> -o - | mpv - ' ?
I live in a mezzanine studio using a M1 macbook for a ...
0
votes
0
answers
30
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 . -...
-2
votes
1
answer
286
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 ...
0
votes
1
answer
119
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, ...
2
votes
1
answer
528
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 ...
1
vote
1
answer
311
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++ ...
0
votes
0
answers
241
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. ...
1
vote
1
answer
83
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, ...
0
votes
1
answer
195
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 & ...
49
votes
1
answer
14k
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 ...
-3
votes
1
answer
476
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,...