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

learn more… | top users | synonyms

3
votes
2answers
117 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
77 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
183 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
0answers
138 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
56 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
137 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
222 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
0answers
72 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
224 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
168 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
292 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
122 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
2k 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
60 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
675 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
71 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
205 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
97 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
34 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
89 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
954 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
77 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
347 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
385 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
2k 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 ...
2
votes
1answer
4k 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
638 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
499 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 ...
0
votes
5answers
544 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 ...
1
vote
2answers
2k 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?
0
votes
2answers
126 views

shell script + match word without echo command

the following test syntax is part of ksh script [[ $PARAM = TRUE ]] && [[ ` echo $LINE_FROM_FILE | grep -c Validation ` -eq 1 ]] && print "find Validation word" Can I get some ...
2
votes
3answers
3k 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 ?
0
votes
1answer
1k 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 ...
1
vote
1answer
277 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 ...
0
votes
2answers
596 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 ...
4
votes
1answer
166 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 ...
1
vote
2answers
5k 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?
0
votes
1answer
1k 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
60 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?
2
votes
1answer
175 views

ksh equivalent of perl $! error reason

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