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

learn more… | top users | synonyms

6
votes
1answer
10k views

How to set default screen colours in putty/ssh

I use putty to ssh to linux box. By default I get black screen background with white foreground. To change colours, I go to change settings -> Window/colours and then I set background colours as ...
4
votes
2answers
612 views

How can I keep reading from a pipe even after the pipe is closed?

I've got a ksh script that calls: while read LINE do... The input has been redirected (not shown) so that it reads input from a pipe. The problem is that when the writer to the pipe closes, read ...
4
votes
3answers
2k views

Unix history not working

I'm using ksh on unix and connect through putty. My .sh_history stores all history commands but when I press up arrow nothing comes, please help me.
4
votes
1answer
188 views

Create a file whose size in bytes is the percentage of free space on a disk

I needed a command-line method of creating a file whose size in bytes is the percentage of free space on a disk. I intend to run it via cron every five minutes, but first a shell script will do. The ...
3
votes
1answer
402 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 ...
3
votes
1answer
308 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 ...
3
votes
2answers
363 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 ...
2
votes
3answers
4k views

unix command to see the last run command on command line

what is the command to see the previously executed command that was run on the command line ?
2
votes
1answer
195 views

ksh equivalent of perl $! error reason

Is there an equivalent of $! in ksh, which provides the error string ? $? stores the exit code only.
2
votes
1answer
286 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
7answers
316 views

Is there a BSD equivalent to “!!”?

I often find myself issuing a command that I do not have the proper elevated privileges for. On Ubuntu I could use sudo !! This would issue the same command with sudo privileges. Is there an ...
1
vote
2answers
8k views

Split a string in ksh

I am looking for a quick/easy way to split a string in ksh. It has varied number delimeters (spaces) between each item. example: value1 value2 value3 Any suggestions/advice?
1
vote
1answer
88 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 ...
1
vote
1answer
732 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 ...
1
vote
1answer
101 views

How to write this script in unix?

How can I write a script for finding the files created by a particular user ID in some locations and tar those files in the same location?
1
vote
1answer
96 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
2answers
100 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 ...
1
vote
2answers
4k views

AIX : retrieving previous command using up arrow

I know about set -o vi and k and j combinations. I want to map these to up arrow and down arrow so that I can use AIX(ksh prompt) just like bash . Any suggestions?
1
vote
2answers
231 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.
1
vote
1answer
851 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: ...
1
vote
1answer
527 views

Using readline keyboard shortcuts in OSX korn shell

I am using ksh on Mac OS X 10.6 xterm (that is, not using Terminal.app). When I try to browse the command history via CTRL+P or try to move the cursor on my prompt via CTRL+B, only the characters ^P ...
1
vote
2answers
1k views

count words in LIST without separators

I have the following simple ksh code: MY_LIST=first,second,third NUM_IN_LIST=` echo $MY_LIST | sed s"/,/ /g" | wc -w ` print $NUM_IN_LIST 3 [[ $NUM_IN_LIST = 3 ]] && print match but I ...
1
vote
1answer
663 views

Re-redirect STDERR in K/SH?

Once STDERR is redirected, for example to a file, how can it be redirected back to the original file descriptor 2? #!/bin/sh exec 2>/tmp/err print -u2 'log errors to file' exec 2>&2 (how ...
1
vote
1answer
304 views

ksh93 as default shell via ssh

I'm a big fan of ksh93. My hosts' shell account doesn't allow me to configure .login, .profile or chsh to change my default shell. As it is, I am dropped into jailshell-3.2 and I have to invoke ...
1
vote
1answer
302 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 ...
1
vote
2answers
387 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 ...
0
votes
3answers
264 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
2answers
9k views

how to fix Permission denied on directory in unix?

I have a ksh file which will download a zip file from the internet in the /tmp directory with name f.zip Why do I get Permission denied? $ ./downloadbcfi Current name is ...
0
votes
1answer
1k views

How can I make an environment variable available outside of a KSH script?

I have a KSH script that exports an environment variable (export SOME_VAR=123) After running the script my current shell is unaffected and echo $SOME_VAR produces nothing. I tried running . ...
0
votes
1answer
80 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 ...
0
votes
2answers
4k views

Tab complete in VI mode KSH 'vi-tabcomplete' gives bad options

When I try stuff like in my .profile: set -o vi-tabcomplete I get: .profile[292]: vi-tabcomplete: bad option(s) Does anyone know of a workaround?
0
votes
1answer
2k views

Find last modified/created file of a certain extension

I created a script file *.ksh very recently and I want to get a list of the last modified/created *.ksh files. I am sure you can somehow do it using find, just not sure how.
0
votes
1answer
37 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
2answers
39 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 ...
0
votes
2answers
62 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 ...
0
votes
2answers
169 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
2answers
1k 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
4answers
89 views

Unix find command help

Hi can anybody help me with the following line; find . \( -type d ! -name . -prune \) -o -type f -name "*Log*" Basically it should find directories where files with "Log" in their name are present. ...
0
votes
2answers
125 views

lines identical except for their first word, put the first word in a variable

I have file(sudoers) in which lines can be identical except for the first word in them (different users can execute the same set of commands). I am able to extract such a line using the command: # ...
0
votes
5answers
730 views

Start linux command with “su” and inline variable

I'm trying to create mozilla profile for another user from command line using su. When I'm trying from X, this will work. su myuser -c 'mozilla -CreateProfile newprofile' But my goal is to embed ...
0
votes
1answer
2k views

How to create a new background process in a KSH “while read” loop?

The following test script has a problem. When I add the line (sleep 5 ) & in the script then the "while read" loop does not read all lines from the file, but only prints the first line. But when ...
0
votes
2answers
817 views

How to repeat commands from history in ksh vi-mode

Say I have a hundred commands in my shell's history, and now I'd like to repeat commands 74 through 78. In the emacs mode of bash/ksh/zsh, I would navigate back to command 74 then hit Control-O on ...
0
votes
1answer
72 views

Is There Any Danger in Closing a Parent Xterm Shell with an Active Child?

When I log into my unix servers, I get an xterm window and usually open several more from that initial one. Is there any danger in closing the first window but keeping the children windows open?
0
votes
1answer
39 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 ...
0
votes
0answers
36 views

Store the filename of the extracted file in a text file

what is the best way to store the filename of an extracted file in a text file? I have a script that extract a single file from a tar file and then I need to store the name extracted file to a txt ...
0
votes
0answers
51 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
1answer
41 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 ...
0
votes
1answer
109 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 # ...
0
votes
1answer
124 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
282 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 ...