Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [ksh]

ksh, short for Korn Shell, is a Unix shell developed in the early 1980s.

0
votes
0answers
39 views

Setting up ksh task in Cmder

I'm looking for a way to use a korn shell in Cmder. I'm trying to add an entry in the Task menu which would let me start a new ksh window. I looked at mksh, to no avail yet. There seems to be some ...
0
votes
1answer
148 views

How to reverse-i-search in ksh through SSH?

I'm currently using PuTTY to connect to some Linux server (ksh on RHEL if that matters). However using Ctrl+R doesn't work (only ^R appears on the screen). I'm quite surprised that despite all my ...
0
votes
0answers
11 views

Get the Connection Response into KSH Script Variable

I'm writing a ksh script that will loop through a list of servers and check kernel version and output this to the screen. This is my code so far: #!/usr/bin/ksh set -x for ssh_host in $(cat ...
1
vote
1answer
55 views

Ksh/Bash script to run commands based on kernel name

I am trying to build a script that will take all hostnames from a file and run various commands depending on the kernel name. I first want to ssh to the host machine and after issuing an uname -a ...
0
votes
1answer
73 views

ksh - Reading an unset variable into an array using the read command

I have the following ksh script, where $an_unset_var is an unset variable which is being used for the first time: read -A arr <<< "$an_unset var" echo ${#an_unset_var} echo ${#arr[*]} ...
0
votes
2answers
420 views

unix shell tips to assign boolean value to variable from a test

code to show the request in context (unix ksh currently): r=$( [ -z "foo" ] && echo true || echo false ) is there a better, simplerway to assign r with true or false something like r=$( [ -...
0
votes
2answers
102 views

How to write a script in ksh to exit from the terminal?

I am writing a shell script. I used case statement regarding certain stuff. I have an option/case as q that should exit from the terminal. case "$i" in 1) some script. ;; q) break &...
0
votes
0answers
878 views

Posting SOAP request through curl command line in ksh

I am trying to post a SOAP request through curl command line. In bash, I am able to get the desired output. However, using ksh I am getting an error: syntax error: "<" unexpected I tried to ...
0
votes
3answers
109 views

keep the first line that matches a string search and remove all following lines that have the same string matched

I am trying to keep the first line that matches a string search and remove all following lines that have the same string matched. Any ideas? $ cat example-input.txt Question one|some other text ...
0
votes
0answers
88 views

Suppress password in shell script debug mode

Is there any way to print an arbitrary string (like 'xxxx' or '***') in place of a password when using shell debug mode. Context - I have few scripts which connects to PostgreSQL database. We have ...
0
votes
0answers
105 views

AIX cut the file size from the ls -l output

Given the 2 lines from the ls -l command: ls -l /text*.txt -rw-r--r-- 1 root root 1307250 Jun 01 10:44 text1.txt -rw-r--r-- 1 root root 697 Jun 01 10:30 text2.txt How can I ...
0
votes
2answers
102 views

KShell script skips commands when scheduled in cron

I have a Kshell script which executes a java program. /path/to/java -jar jarfile.jar some parameters > log Same line 5 times with different parameters appending output to log file. cat log | mail -...
2
votes
2answers
874 views

Unix find not working with a wildcard in the path when ssh'ing

This command with a * in the find path works fine on the local server Svr1$ find /path/*/foo/ -name "*20160208" When I try this remotely from another server it doesn't work Svr2$ ssh Svr1 find '/...
1
vote
2answers
2k views

Using wildcard in unix find command's path

This command with a * in the find path works fine on the local server Svr1$ find /path/*/foo/ -name "*20160208" When I try this remotely from another server it doesn't work Svr2$ echo $Pswd|ssh ...
0
votes
1answer
41 views

Fold on “short form of here document”

Apologies for the x-post from stackoverflow, but there appear to be views of [notepad++] here. According to the man ksh or man bash page (RHEL 6.6.0) <<< word is the equivalent of: <&...
-1
votes
4answers
226 views

With KSH, how to convert “12345” to “1.2.3.4.5?”

With KSH, if I have a string 12345 and I want to it be converted to 1.2.3.4.5, how can I do that? I tried to use cut but it's not straightforward. echo "12345" | cut -c1
0
votes
1answer
586 views

Assign Substr of a string to a variable

I am new to unix script. i am asked to modify a ksh script. it requires i assign a substring of a string to another variable. I tried below and its not working GET_OLDEST_FILE=`ls -ltr *$...
1
vote
1answer
2k views

Interactive Script; Prompt within a loop

How do I prompt a user for input from a shell script (ksh) within a loop in which a file is read? The script reads in a file. In each loop pass the user will be asked if he wants to cancel or not? ...
2
votes
1answer
1k views

Issues using scp to copy a file in Unix

I have a script where i need to get the cksum of the files in a directory from another host. I was able to do ssh to another host and create the file.txt. what i need to do now is to scp the file ...
2
votes
1answer
393 views

unix - sort content of two folders then compare using diff command

How do I sort contents of two different folders before comparing those two directories using diff?
4
votes
1answer
22k views

What is the difference between “elif” and “else if” in shell scripting?

I am very new to shell scripting. When I look at some code, written for ksh (#!/bin/ksh) I see there is else if as well as elif used in one script. So, what is the difference between else if and ...
2
votes
1answer
516 views

Pipe standard error to file and keep it on standard error?

I have a script (fragment) for which I'm logging output and standard error: #!/bin/sh #... { date "+%Y-%m-%d %T" cd $workdir ls -ltr validfile badfile #example command that provides stdout, ...
0
votes
0answers
213 views

ksh script using if break statements

I have a script file that has the server details like set -A SERVERGRPS SERVERS_CA SERVERS_NY set -A CA ca126 ca546 ca 642 set -A NY ny112 ny113 ny114 now I have to write a another script which ...
1
vote
1answer
917 views

using sed to replace 1 line with a multi-line variable in ksh

I have the following text in a file: XXXX NNNN YYYY NNNN ZZZZ NNNN I want to replace the NNNN to make it look like this: XXXX NNNN DUTY FORECASTER: YYYY NNNN DUTY FORECASTER: ZZZZ NNNN ...
0
votes
1answer
276 views

Solaris: a simple script does not work, single command does

In my Solaris Illumos, I run a simple script: update_drv -a -i '[myhardware]' [driver] svcadm disable stmf svccfg import /mypath/myconfig svcadm enable stmf It does not work and gives me no ...
1
vote
2answers
1k views

Is there a way to show “File not found” or a message alike when using the `find` command?

I'm trying to check the existence of several files, without knowing in advance where the files are located. So, I thought of find as the de facto utility to do this... It works as expected, but the ...
2
votes
1answer
10k views

Infinite loop in Terminal (ksh) to launch commands

I'm trying to create a loop in terminal to launch every second during the execution of an script the following command. I don't want to create the loop in .sh script file, i'm trying to do in the ...
1
vote
1answer
1k views

Using a while loop to read a file, randomly stops reading the file in the middle [closed]

I have a small section of code that reads a file, $FUNCTION_FILE which contains a list of function names in the format: func1 func2 func3 It will read a line, run the function, and repeat until the ...
4
votes
1answer
2k views

Does “ulimit -Su” limit the number of user processes created in interactive login subshells and tmux sessions created therein?

A few months ago, I wrote a set of bash scripts utilizing tmux to create a simple IDE on an AIX 7.1 server. There is a bug in one of my scripts that will sometimes generate user processes very rapidly ...
2
votes
2answers
3k views

Convert Month Number to Month Name

Is there a way to convert month number to name with a script? example: 2013-10-22 will become Oct 22 Thanks. BTW, I don't have the GNU date and my OS is AIX.
0
votes
1answer
799 views

ksh double quotes and variables

It's a KSH problems. I have encounter some problems with variables and quotation marks today. Order doesn't matter, although i cannot read the scripts but only execute it. SomeScripts.sh "First=...
2
votes
1answer
2k views

Extract a single file from a tar file to another directory

I have a tar file and I need to extract a single file from it and put it to another directory. I tried this but it gives an error message. It did extract the file but not to the directory that I want ...
2
votes
1answer
9k views

Adding a month to an input date in unix

I need to write a script that asks user for an input date. Then I need to add a month to that date or at least 30 days. Example: Date: 2009-05-12 I need to get 2009-06-12 this code is not working: ...
2
votes
0answers
650 views

How to read aliases in a ksh script

I have some global aliases defined in my ~/.profile file. To read them from a bash script, I'd use: shopt -s expand_aliases source ~/.profile However, in ksh this does not work because it does not ...
0
votes
2answers
74 views

How to search for broken links on the entire local file system of a server?

I have to do this in korn because bash is not installed. This is my script so far but it's not quite working as I expect. cd / find . -xdev -type d > /tmp/dirlist export YOURLIST=`cat /tmp/...
3
votes
1answer
1k views

Delete old log files in AIX

I am trying write a script to delete old log files in \var\log\applog\nmon on my AIX system. We usually get alerts that the file system is almost full and at the moment delete old files by hand. So ...
0
votes
2answers
1k views

Korn Shell .kshrc

I'm trying to make the UP arrow to get previous command in Korn Shell but I can't find .kshrc file in my $HOME directory. I know it is hidden but even ls -al doesn't show it. What should I do?
0
votes
1answer
66 views

Queue commands to last subshel even if one of them launches new shell

I want to automate something writing simple script launching consecutively few scripts one after another. And then setting some aliases at the top shell. Problem: few of these commands launch new ...
3
votes
2answers
979 views

Unix HP-UX ksh recursive find and replace

I am trying to do a recursive find and replace in HP-UX and am missing something. What I have at the moment: find . -name "*.java" | xargs sed 's/foo/bar/g' I know the problem is that it's not ...
0
votes
1answer
143 views

for loop non-ending, loop never procedes to second argument

I am trying to use the "for name in" to loop through a list of values. It uses the first value in the line but sticks in a never-ending loop. #!/bin/ksh set -x # created 7 JAn 2013 by L Cooper # ...
1
vote
2answers
1k views

Difference between running commands locally vs using SSH to make remote commands

I am trying to SSH into a remote machine, and run a .ksh file on a that machine to run a Java program. If SSH into the machine with a tool like Putty, and run this command: cd /folder/folder/...
2
votes
1answer
669 views

Up key for XTerm, Korn shell (while vt100 through telnet/putty works) dont work

I am using xterm on korn shell. I have defined in .kshrc as follows: set -o emacs alias __A=`echo "\020"` # up arrow = ^p = back a command alias __B=`echo "\016"` # down arrow = ^n = down a ...
1
vote
2answers
163 views

FIND operands and order of arguments

I have a find command that I am unsure if I am placing my arguments correctly. find / -xdev -size -size -262144000c -o -type d \( -name .snapshot -o -name man -o -name Man -o -fstype mvfs \) -prune -...
14
votes
1answer
6k views

overriding user defined functions with the same name as system commands

This function exists in one of my users' ~/.bashrc: function rm() { ls $* echo "rm?" read ans if [ "$ans" == 'y' ]; then /bin/rm $* fi } In my ...
2
votes
2answers
5k views

Fastest way to get creation and last modification times of a lot of files

Given a directory a sh pattern which yields a subset of files directly in this directory (like *.log) a sh pattern which can, given a filename, what is the fastest way (in ksh) to obtain for each ...
0
votes
1answer
197 views

dynamically allocating space for variable in ksh

I am new to ksh unix shell scripting.I need my ksh script to get inputs from the user. and the number of inputs is unkown. I need to get the inputs and process again further .The sample run could be :...
0
votes
1answer
405 views

“shell not found” on start of backtrack 5

I am using backtrack5 in VMware on my system. I was trying to change my default shell to ksh. After executing the 'chsh' command. On restarting the OS, it shows "Cannot execute ksh: no such file or ...
1
vote
3answers
409 views

What will happen when I 'cat' 'ksh'?

I used the following command in my unix box. $ cat ksh And it gave a rolling log of latin and greek letters and symbols and it kept on going with no signs of stopping. Eventually I had to close my ...
0
votes
1answer
721 views

Solaris/Linux - tput command + create bold text

How do I bold the "Date & Time" numbers from the following file with the tput command (I have a Solaris machine)? For example, I want to bold only the "24-09-2009 16:17:45", etc. for all other ...
0
votes
2answers
208 views

Generate new file with specific structure from text file

On Linux I have the file orig-file.txt. This file include 4 fields now, but they could be less or more (this file is generated by other application). What is the best option to translate the orig-...