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

learn more… | top users | synonyms

1
vote
1answer
26 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
30 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?
2
votes
1answer
69 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
26 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
63 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 ...
0
votes
1answer
155 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
66 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
2answers
47 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 ...
1
vote
1answer
377 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
180 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 ...
3
votes
1answer
677 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 ...
1
vote
2answers
365 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
0answers
42 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 ...
-1
votes
1answer
135 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 ...
1
vote
1answer
590 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
1answer
1k 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: ...
0
votes
0answers
78 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
64 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 ...
3
votes
1answer
422 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
244 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
45 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
438 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
116 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
440 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 ...
2
votes
1answer
350 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
105 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
1answer
1k 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 ...
0
votes
2answers
2k 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
136 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
309 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 ...
0
votes
3answers
290 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
507 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
173 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 ...
0
votes
2answers
11k 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
0answers
61 views

Sorting a list of directories that contain numbers with a different number of digits [duplicate]

Possible Duplicate: In bash, how to sort strings with numbers in them? We have the following directory structure on our file-system: ver30 ver20 ver50 ver70 ver100 ver90 I want to create ...
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
4answers
94 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
1answer
779 views

Script that runs a command with 'exec' doesnt end until 'Enter' is pressed

We have a KSH script that runs a process using exec and hangs. We want to be able to run it automatically and keep it running in background. We tried this: ./myScript.ksh & However this left ...
0
votes
2answers
133 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
1answer
38 views

How to write code for this archival scenario?

Say after the 1st run, 10 files got created with def user id in abc directory. I tarred the 10 files created by def user id in a tar file with date time stamp extension. Now after the 2nd run, ...
1
vote
1answer
105 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?
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.
0
votes
0answers
94 views

Overlapping lines in AIX 5.3

When I type commands and hit enter my cursor line for some reason appears on the the second line from the end of the output: tomcat [server] /home/tomcat: ls -l total 24 -rwxr-x--- 1 tomcat dev ...
4
votes
2answers
731 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 ...
1
vote
1answer
568 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 ...
0
votes
1answer
3k views

ksh Auto-Completion PuTTY Configuration

I'm having a bit of a problem configuring my PuTTY client to work with the auto-completion feature in the ksh shell. I do a listing on the root with the directories /home and /homeroot and it returns ...
1
vote
7answers
336 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 ...
9
votes
1answer
13k 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 ...
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
798 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 ...