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.

learn more… | top users | synonyms

13
votes
3answers
7k views

Getting size with du of files only

How can I get the size of all files and all files in its subdirectories using the du command. I am trying the following command to get the size of all files (and files in subdirectories) find . ...
1
vote
1answer
556 views

How to call a generic function without importing its file?

Assume I have a function.ksh file that contains a function called getServerIp. I don't want to create a new script file and import function.ksh, I just want to run getServerIp from my current shell. ...
1
vote
0answers
540 views

Dynamic search and replace in Ksh

Machines at work follow a constant naming pattern: host[domain]_[id] where [domain] is either "d" for dev machines and "p" for production machines, and [id] is a 2-digit string that is different for ...
5
votes
4answers
6k views

Is there a way to sum up the size of files listed?

This is the command I am using to list some files: find . -name \*.extract.sys -size +1000000c -exec ls -lrt {} \; -rw-r--r-- 1 qa1wrk15 test 1265190 Sep 29 01:14 ...
6
votes
5answers
931 views

Shell programming, avoiding tempfiles

I often write KSH shell scripts that follow the same pattern: (1) retrieve output from one or more command (2) format it using grep|cut|awk|sed and print it to the screen or to a file In order to ...
1
vote
1answer
210 views

How to replace the original value of variable in HTML tag

I am facing some problems in replacing the value of a variable in a html tag in a unix box. Here are the details. Please help me in finding a solution. #!/bin/ksh count=5 ...
3
votes
2answers
185 views

Execute command on shared account login

At work our team uses a shared account "appadmin" to administer our application. At login, each one of us sources an "aliasrc" file containing his or her preferences. (aliases, display, prompt, ...). ...
4
votes
6answers
423 views

What should I do with a remote AIX machine if I accidentally “chmod 644”-ed the “/usr/bin/ksh”?

Now the machine asks for password...The ssh was configured with key auth.. The problem is that ksh doesn't has executable permission anymore.. :\ What can I do remotely? Any tips? The root's shell ...
3
votes
2answers
5k views

Replace all occurrences of a character in a variable using korn script

Part of the Korn script I am writing requires that I replace all occurrences of the ' character with two occurrences (''). I am trying to log some SQL that I am generating in this script to a column ...
2
votes
3answers
698 views

regexp in ksh for extensions tgz, tar.tgz

I'm trying to get a regexp (in ksh) to identify files with only the following extensions: tgz, tar.gz, TGZ and TAR.GZ. I tried several but can't get them to work. I'm using this regexp to select only ...
3
votes
3answers
3k views

Get the number of files that match a pattern in a directory and delete the oldest one

I'd like to do the following: Get the number of files in a given directory that match a given pattern, for example: ExtractBackup_{date}.tar.gz If that number is 2 or higher, delete the oldest file ...
7
votes
1answer
560 views

Poor Man's GNU Parallel implemented in ksh?

I'd like to use the feature of GNU parallel where it can execute the command and the list it's fed in parallel and spit it out after it's all done, however, I don't want to install GNU parallel across ...
2
votes
1answer
511 views

Tutorial about key maping in KSH in EMACS mode

Are there any good tutorial to learn about Key Maping in Korn Shell (AIX) in EMACS mode ?
2
votes
2answers
740 views

Create a new file by removing the new line character at the end of file

I have a flat file which contains the following data records between H: and T:. H:20050427 HEADER RECORD 0000000 00000 000000000 123456 00 654321 DATARECORD 0000000 00000 000000000 123456 00 654321 ...
14
votes
2answers
833 views

How can one time out a root shell after a certain period of time?

Is there a way to 'time out' a root shell (for example, in gnome-terminal) so that after a certain amount of time not issuing any commands, the shell exits? I'm searching for a solution that works in ...
3
votes
2answers
609 views

ANDed conditional using regexp and variables

I want to test whether a line, read in from a file, has a specific beginning AND an ending containing a word held in a variable. Here's some code: The input file is: line one #; line two #; line ...
6
votes
2answers
2k views

Adding Ctrl-L as “clear” hotkey in OpenBSD's ksh

I've been looking for a way to use Ctrl-L to clear the monitor instead of typing clear in each time. I found nothing except a patch which didn't work for me. How do I add hotkeys/shortcuts to my ...
2
votes
2answers
423 views

What could cause which to not show something in the path?

There is an executable in my path that I believe is a perl script. >$scriptname $outputofscript but >which $scriptname which: 0652-141 There is no $scriptname in $path and the path it ...
3
votes
2answers
4k views

How to catch optioned and non optioned arguments correctly?

I want to write a shell script which will take some arguments with some options and print that arguments. Suppose the name of that script is abc.ksh. Usage of that script is - ./abc.ksh -[a ...
5
votes
2answers
1k views

Shell script execution on multiple servers

Is it possible to run one part of the ksh/sh script on one server then ssh to another server and continue with the rest of the script? or is there a way around? Anyone had experience with this ? here ...
28
votes
5answers
2k views

When do you use brace expansion?

I understand what brace expansion is, but I don't know how best to use it. When do you use it? Please teach me some convenient and remarkable examples if you have your own tip.
3
votes
3answers
3k views

Using nohup on Solaris 10

I need to transfer a large number of files over SFTP (only between Solaris servers) which takes a very long time. I cannot keep my PC on for this duration. I tried: nohup sftp server1 While the ...
6
votes
1answer
2k views

Reason for ksh obsoleting -eq

The latest version of ksh obsoletes using -eq within [[ ]] blocks, prefering (( )) instead. Why is this? I can't find any documentation on the advantages of (( )) over [[ ]] anywhere, and I find that ...
0
votes
0answers
608 views

bash get file name and extension [duplicate]

Possible Duplicate: bash : get file extension I have file names like below filename.jar filename.tar.gz filename with no extension ...
5
votes
4answers
3k views

How to have separate command history for different sessions for the same user?

I face this issue on some of Unix servers. When I open different session for same user, command history is shared by all the session. This creates issues if by mistake I press Ctrl-P or up arrow and ...