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

2
votes
2answers
127 views

linux & solaris - separate netmask IP's from ordinary IP's

I have file with IP address and netmask IP's my target is to cut the netmask IP's from the file_with_IPs.txt and paste them to another file as file_with_only_netmask_ips.txt remark - netmask IP can ...
-3
votes
4answers
357 views

perl one liner + how to replace any last IP address octets

How to replace any last IP address octets (four octet ) to 0 remark: Implementation should be by Perl one linear on linux machines for example 192.9.200.124 will replaced to 192.9.200.0 ...
-1
votes
1answer
54 views

Strange combination of symbols UNIX [closed]

I was looking at one korn shell script examples and I saw this strange combination of symbols: %? So my question is what does it mean?
1
vote
2answers
1k views

Scrip to delete files older than 6 months

Setting up a cron job for once a month to start a script. the script is to rotate a file each month as it gets too big and rename the old one. when a file is older than six months I wanted it to be ...
1
vote
1answer
889 views

Comparing file times in ksh

I have developed a script which will compare two dates. #!/bin/ksh #################################################################### # #DECLARING ALL THE VALUES AND PATHS # ...
4
votes
2answers
2k views

How do I capture the return status and use tee at the same time in korn shell? [duplicate]

Consider Source code: 1. Parent.sh #!/usr/bin/ksh # No tee ksh Child.sh; exit_status=$?; echo "Exit status: ${exit_status}" # Using tee ksh Child.sh | tee -a log.txt; exit_status=$?; echo "Exit ...
1
vote
2answers
491 views

linux + match IP ADDRESS with 3 octets or with 4 octets

how to match IP address with 4 octets or with 3 octets in one command? target - match xxx.xxx.xxx or xxx.xxx.xxx.xxx ( syntax should fit for Linux and Solaris ) how to merge the following commands ...
4
votes
4answers
243 views

linux + how to ignore (filter) file with space

Sometimes a file name is created from a couple of names and space between each name as the following: $ touch "A B C" $ ls A B C <-- one file but has three words ! ...
3
votes
1answer
204 views

Why is uname -M returning an empty string?

On the exact same machine (AIX 6.1), in 2 different login shells (both ksh), with different user IDs, I can do uname -M; in one shell I get the system model. In the other shell I get BLANK! The only ...
3
votes
1answer
574 views

Trapping dot (.) file not found errors in KSH

In ksh88, I can source a file using the "dot" command, like . /my/file/source.ksh However, if source.ksh doesn't exist, I want to trap the error. So I tried this: #!/bin/ksh trap "echo 'Source ...
3
votes
1answer
321 views

Output of `java -version` not matched by grep or awk

On my Linux machine, it isn't clear to me why if I do the following then I don't get only the version string ("1.5.0_32"). # java -version | grep version | awk '{print $NF}' java version "1.5.0_32" ...
0
votes
3answers
294 views

Sorting IP address according to the second field in file

in my ksh script I need to add the following task ( OS - linux/solaris ) I have the following file more test.txt /etc/backup/app 172.1.120 172.110.120 /etc/backup/app 172.1.120.12 ...
3
votes
1answer
884 views

Installing ksh as the standard shell in Redhat: Foolhardy?

I'm not a system administrator, but my organization is considering replacing /bin/sh in Red Hat Enterprise Linux 6+ with a hard link to /bin/ksh. How foolhardy would this be? The background to this ...
9
votes
7answers
785 views

determine shell in script during runtime

As per my knowledge, to determine the current shell we use echo $0 in the shell. Rather I want my script to check in which shell it is running. So, I tried to print $0 in the script and it returns the ...
0
votes
2answers
912 views

How to call a KSH script from another KSH script

I want to call a KSH script a KSH script. Script 1 performs the following: Loops thru a list of database server Perfroms a query Appends output from query from each database server to a txtfile ...
0
votes
1answer
722 views

Must parse ls -Al output and get file or directory name [duplicate]

I must parse ls -Al output and get file or directory name ls -Al output : drwxr-xr-x 12 s162103 studs 12 march 28 2012 personal domain drwxr-xr-x 2 s162103 studs 3 march 28 ...
1
vote
3answers
1k views

output only file names(with spaces) in ls -Al

I should echo only names of files or directories with this construction: ls -Al | while read string do ... done ls -Al output : drwxr-xr-x 12 s162103 studs 12 march 28 12:49 personal ...
1
vote
2answers
505 views

Find all directories, in which user has access to search and echo this directories in shell

I need to find all directories, in which user has access to search(command find) and echo this directories in shell. USER is read from ksh. for example: read user I know, if user want to use find ...
4
votes
2answers
1k views

How do I escape a sub-directory name with an ampersand in it?

Running a kornshell and trying to traverse a directory tree. Want to cd to a sub-directory named as follows: -3ab_&_-3dc.img My question is HOW do I need to escape the ampersand in this name? ...
2
votes
3answers
612 views

Find directories that do not contain subdirectories

I'm writing script is ksh. Need to find all directory names directly under the current directory which contain only files, not subdirectories. I know that I could use ls -alR and recursively parse ...
1
vote
1answer
106 views

What rules govern the parent-child relationship of processes launched by shell across a pipe?

#!/bin/ksh # start_service: start the service my_server_executable 2>&1 | my_pipe_following_shell_script & exit 0 After I run the above start_service script from command line, it is ...
5
votes
1answer
126 views

Find all users who have more than N processes and echo them in shell

I'm writing a script in ksh. I need to find all users who have more than N processes and echo them in the shell. N is read from ksh. I know that I should use ps -elf, but how do I parse it, find ...
0
votes
2answers
93 views

perl one liner + print VALUE in the end of the line

The following perl one liner checks if $CURRENT_VERSION matches $NEW_VERSION exactly, and prints it if it does. Example: CURRENT_VERSION=223.3.12.4.5.3 NEW_VERSION=223.3.12.4.5.3 DATE=17.3.2013 ...
3
votes
4answers
2k views

Piping output to text file within a for loop

I'm trying to do the following within a for loop: Find files that satisfy a condition Echo the name of the files to a log file. Gzip the file. I can get the script to find the files and echo their ...
0
votes
1answer
526 views

Rename files and directories with a special characters on solaris machines

The target of the following code ( commands ) is to rename files/directories and also support files/directories with a special characters as "@" or "." etc those commands are run fine on Linux ...
1
vote
3answers
2k views

How to scp with regular expressions

I'm trying to copy all files that do not begin with the letter "a", in ksh. Copying from the source machine to destination machine is working fine: scp -p !(a*) user@machine:/path/directory/. But, ...
3
votes
1answer
1k views

Delete key doesn't work on command line

*Note: I asked this same question on SuperUser, but didn't get any response. I now realize this is a more appropriate forum for this particular question. In a ksh shell, the Delete key doesn't work ...
0
votes
1answer
192 views

Solaris 10, Shell Script, Cursor movement [closed]

#include <signal.h> #include <unistd.h> #include <stdio.h> #include <sys/types.h> #include <time.h> void prtime() { time_t rawtime; struct tm * ...
1
vote
2answers
395 views

case + how to implement equal or less or greater in case syntax

My target is to verify a range of number with (only with case + esac), and print the range. So for example: If the number is between 0 and 80, print >=0<=80 If the number is between 81 and 100 ...
2
votes
1answer
1k views

Bash vs ksh pipes

I am stuck with some problems with my scripts in ksh. FWIW the problem which I am unable to overcome is that when I use a structure such as this command | while read VAR1 do many.commands using ...
2
votes
2answers
782 views

Del key in AIX ksh over PuTTY telnet

At the place where I work we're developing under AIX with ksh and connecting to it via telnet. Most people use ArcTel to connect, while I prefer PuTTY. The only problem I have with PuTTY is that the ...
-2
votes
2answers
682 views

History command in ksh not able to use [closed]

I am using the ksh shell. I am not getting any impact of these following commands. It is executing without any error but it is not giving the proper results. export HISTTIMEFORMAT='%F %T ' Use the ...
0
votes
1answer
580 views

ksh - map Ctrl-D to exit shell

I would like to know how we can map the keys Ctrl-D in ksh to exit the shell as it does in bash shell. Not much familiar with key binding in ksh. Edit My comments are after the <!-- string ...
2
votes
3answers
3k views

How to iterate through a comma-separated list and execute a command for each entry

I have been give a command which outputs a comma-separated list for autosys jobs in the variable $all_jobs: box=box-of-jobs;all_jobs=$(jobscout -box $box | egrep "^\w+" | tr '\n' ',' | sed s/.$//); ...
1
vote
1answer
488 views

Reading the contents of the file and splitting using ksh

We're using a ksh script for installing one product. I've another config file, I'd need to read this configuration file from my main script Content of the Configuration file: ...
0
votes
2answers
382 views

Comparison of shells? [closed]

Do shells have any actual advantages or disadvantages? They can all run any binary, they all support pipes and > (output to file). Why would one choose bash over sh, or sh over ksh, etc? Why does ...
2
votes
1answer
1k views

Ksh Script to ftp multiple directories simultaneously

I'm new to this site and i have this problem: I have a directory in unix with multiple directories in it. Each directory have around 5k files in it. So we are talking about 40k to 50k files. I need ...
1
vote
2answers
1k views

Pattern matching from the input arguments

we're trying to enhance the scripts. Users will pass some arguments and part of the arguments will have 5.0.3 For an example the input argument would be like Jboss5.0.3GA. Since it ( Jboss5.0.3GA ) ...
2
votes
1answer
615 views

How to find old directories in local directory using find in AIX?

I need to find all old directories in current directory. find in AIX does not provide -maxdepth parameter. There is only -depth and -prune parameters. It is possible to write something like following: ...
3
votes
1answer
491 views

Why does sendmail work differently in different shells?

The following code works when I directly run it in bash shell: SUBJECT="SUBJECT-"`date`; MAIL_FROM="abc@site.com"; MAIL_TO="abc@site.com"; MAIL_CC="abc@site.com"; MAIL_FILE="/path/of/html/body.html"; ...
1
vote
1answer
84 views

Unsure about the behaviour of my script when writing to log file

I have a very simple ksh script and at certain points I want to write to a log file. I use the following commands in two places... print "Directory listing 1:\n" > ${LogFile} ll >> ...
1
vote
1answer
536 views

How to create an alias that takes an argument in KornShell

I am trying to create an alias which when given some argument will look for the folder with contains the argument as pattern. Let the alias name be gohf. Now, I will be using this alias like gohf ...
1
vote
1answer
183 views

How do I ensure that only one instance of my ksh script runs on Solaris using NFS? [duplicate]

Possible Duplicate: What Unix commands can be used as a semaphore/lock? I have read many similar post and the solution seems to be to use flock. flock does not exist on my system and I ...
3
votes
3answers
2k views

Solaris: find the day of last Monday,Tuesday,…Sunday by means of shell script

I'm trying desperatly to find a bash or ksh routine that allows me to find for example the previous Monday,Tuesday,Wednesday,... preceding today's date. Additonal it has to work on plain vanilla ...
3
votes
3answers
6k views

How to use cut command to get the first and last elements of a row?

I've asked almost the same question already, but this time, I want to retrieve the X latest elements of a row of a CSV file. For example, with an input file as this one: 1;foo;bar;baz;x;y;z ...
1
vote
3answers
439 views

linux/solaris + verify duplicate valid IP address from file

what the best way to find duplicate IP from file ( I have ksh script in this script I need to write function that check for duplicate IP ) for example if IP - 192.1926.23.52 exists twice in file - ...
3
votes
1answer
741 views

Capture screen content for error parsing

I am a database administrator working with DB2 on AIX. (Please continue to read as this is related more to ksh than DB2, otherwise I would have posted this over on dba.stackexchange.com.) I am ...
3
votes
2answers
569 views

Error when subtracting two negative numbers in ksh: “assignment requires lvalue”

I am trying to debug someone else's script: The code line is: y=$((${oldvalue[$x]}-${newvalue[$x]})) y gets calculated fine as long as both sides are positive numbers. However, I have a ...
2
votes
3answers
3k views

Storing a list in a variable

I am trying to store the name of list of files that contain 781 in their name. I will be using this list to perform some operations and after that I will delete this list. I have two options to do ...
4
votes
1answer
462 views

Ksh loses data after piping 16K bytes

I recently found that ksh may lose some data after printing more than 16K bytes to the stdout if it is blocked for a couple of seconds. This test.sh script prints out 257*64 (16448) bytes: ...