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
1answer
27 views

Using directive and namespace aliasing with Ksh

Can I create an alias for a korn shell namespace? Is there anything like the using directive in C++ (bring several namespaces together and throw a (compiler) error if a symbol designation is ...
0
votes
2answers
32 views

How to open compressed file in less mode [duplicate]

How do I open a compressed file in less mode. I am able to grep using zgrep and using zcatI can open, but the file is big I want to open in less mode.
1
vote
1answer
26 views

How to convert a generic xml format block to properties format String from an xml file using ksh script [closed]

With the conditions: I cannot use any XML parser tool as I don't have permission , read only My xmllint version does not support xpath, and I cannot update it , read only I dont have xmlstarlet and ...
1
vote
2answers
42 views

Unable to store ascii value in a variable

I am trying to convert hex to decimal to ascii and store it in a variable. I am using the following code. HEX=30 DEC=`printf "%d\n" 0x${HEX}` echo "$DEC" ASC=`printf \\$(printf '%03o' $DEC)` echo ...
1
vote
1answer
27 views

Passing multiple varibles to a script for SQL query

I have this script called info_code: #!/bin/ksh if [ $# -eq 0 ] ;then echo "Enter code : \c" read code echo "" else code=$1 fi code=`echo ${code} | tr '[a-z]' '[A-Z]'` echo "select * from ...
1
vote
4answers
126 views

How to use and/or conditional in shell script

I have an if statement in a script. It looks like this: if [ "$a" != "0" -a "$b" != "100" ]; then #some commands here If I'm not mistaken, the line above will work if both conditions are true. ...
0
votes
1answer
32 views

Convert particular lines in a text file to bold [closed]

I have a text file with 100 lines in it. I want to convert particular lines, lets say line1, line6 , line27, line 48, line 86, line99 to bold. I am using solaris 5.10, with KSH. Is there a way I can ...
1
vote
2answers
45 views

concatenating file names in a variable

I am attempting concatenate file names to use in a ftp mdelete command. Each file name needs to be separated by a space in order for the mdelete command to work. The $i variable is in a loop and I ...
1
vote
1answer
20 views

How to respond in a prompt using exec channel of JSch

I need to respond to a prompt generated by a command, for example ssh hostname then a password prompt appears and the script must automatically enter the password after the prompt. I tried ...
0
votes
2answers
25 views

Unable to perform a simple multiplication in script

I am havingf trouble performing a simple multiplication in my script. while read A B C do tmp=$A\*$C/100 echo $tmp >> out1.txt done < foo.txt foo.txt: 13721725 99 100 ...
0
votes
4answers
43 views

tabs in variable not working

I have this lines that i will insert in a mail called "header". header=" ------------------------------------- Name\tAge\tGender\tAddress ------------------------------------- " Unfortunately, the ...
4
votes
5answers
302 views

How to delete files from a folder which have more than 60 files in unix?

I want to put a script in cronjob which will run in a particular time and if the file count is more than 60, it will delete oldest files from that folder. Last In First Out. I have tried, ...
1
vote
1answer
40 views

How do I renice my login shell?

I'm on a multi user login-node, a front end node to a large national bioinformatics compute farm, running Linux. Many users misbehave by running computationally intensive jobs on the login-nodes. I ...
0
votes
4answers
71 views

Unix bash/ksh : Selection of first non space character from file from specific line

I have file file1.txt whose contents are as follows: Date List ----------- Quarter Date Year Date Month Date Now I want to read the non space elements from each row of ...
1
vote
2answers
26 views

Addition of values

foo.txt: Lillypaul_sg 204803 204803 204803 Ammy_sg 3 ramaswamy_sg 3 33 tommy_sg 3 3 137374 100 Desired Out.txt : Lillypaul_sg 614409 Ammy_sg 3 ramaswamy_sg 36 tommy_sg 137480 The output is a sum ...
0
votes
2answers
42 views

while read loop

I have a file like one below var 3 2014 string var1 4 2011 string4 var2 6 1999 string2 var3 1 2016 string6 Then i have this while read loop to compare one of the ...
6
votes
4answers
255 views

Is there a way to display all the scripts called from some other script?

I have a large number of scripts that I need to modify. Each script probably calls 5 to 10 other scripts, which in turn might call several other scripts, and who knows how deep that rabbit hole runs. ...
0
votes
2answers
36 views

Issue on awk input parameter in ksh

I am running this script: INPUTNAME=ABC.XYZ FILENAME="Sample.xml" awk -v inputName=$INPUTNAME ' /<machine.*name=/ { f=1 ; m=0 ; res="" } f { res = res $0 ORS } f && ...
0
votes
1answer
41 views

How to implement awk range pattern in fetching an xml block when the input parameter is in the middle of the block

I am trying to fetch an xml block like this: <machine name="sample1" min="1" max="10" idleTime="300" backend="ABC,XYZ"> <handler className="com.abc.xyz.qwerty.foo.FooBar" ...
0
votes
5answers
112 views

How to grep an xml block in an xml file using a keyword in ksh

I have a file Sample.xml which contains a lot of services inside it and the structure looks like this Notes: I cannot use any XML parser tool as I don't have permission , read only My xmllint ...
0
votes
3answers
52 views

How do I pass a series of patterns into awk from a shell script?

I've got a series of patterns stored in foo.txt and I want to iterate over those patterns and see which match lines in file bar.txt. while read PWW do cat user/dump/bar.txt | awk '/${PWW}/{print ...
1
vote
2answers
49 views

Substrings in shell script

Am trying to get a substring from a string but am getting the error: ${curr_rec:3:4}: bad substitution #!/bin/ksh get_file_totals() { if [ -e "$file_name" ] then IFS='' ...
0
votes
0answers
42 views

Avoiding heredoc sh[process_number].* files in /tmp directory

I have a .ksh file which logs into sqlplus and runs some queries. The block of code is something as mentioned below: //Other things done in ksh sqlplus -s @connect.sql << EOF Query1 Query2 ...
0
votes
4answers
101 views

Hexadecimal number sequence checker in Linux?

I have a list of hexadecimal number. I would like to check whether they are in sequence or not. That is, they should be consecutive numbers, in increasing order. In other words, there should be an ...
1
vote
2answers
96 views

use SFTP in shell script

I have written a shell script to get the files from another UNIX server. But files are not being copied. Could someone help me what I am doing wrong. sftp username@server:$path get ubpbilp* ./ mget ...
2
votes
2answers
65 views

Reliably identifying the path to the directory containing the running script

There are plenty of answers in SO to address this question: Can a Bash script tell what directory it's stored in? Unix shell script to find out which directory the script resides? And there are a ...
1
vote
1answer
60 views

Pattern matching inside awk

I intend to modify the output of ls -la to display the output of file command. The below command works well for the purpose find /opt -type f | xargs ls -let | awk 'BEGIN { OFS="\t" } { sprintf("file ...
2
votes
3answers
55 views

Search a String in a directory- Get output without filename

I am executing the below command to display the lines which matches the pattern. find ./files/ -name "*.txt" -print0 | xargs -0 grep "5|20150507" And output is ...
0
votes
1answer
59 views

Solaris: How to run a system command on top of awk and combine all output in a single line

Have this peculiar requirement to print files in a given directory in the below mentioned format filename1 <type of file> owner group filename2 <type of file> owner ...
4
votes
2answers
107 views

Checking if a command is a built-in in ksh

How can I check if a command is a built-in command for ksh? In tcsh you can use where; in zsh and bash you can use type -a; and in some modern versions of ksh you can use whence -av. What I want to ...
1
vote
2answers
38 views

Read the file from one Unix server to the other Unix server

I have a Pro*C program which I run on Unix server a but the input file required for this program is on other Unix server b. Whenever I run I have to copy the file from server b to a. Is there any way ...
0
votes
1answer
69 views

FOR loop not looping

I have the below script that uses 2 for loops. for some reason they loop is not looping #! /bin/ksh CURR_PATH='/main/nedcor/flexcube' cd $CURR_PATH for DIR1 in 'WIP' 'INPUT';do echo $DIR1 ...
5
votes
5answers
475 views

How can I safely get the version of ksh?

How can I safely get the version of ksh from within a ksh script? I have seen the following solutions: ksh --version echo ${.sh.version} echo $KSH_VERSION And if the circumstances are perfect, ...
1
vote
1answer
33 views

Is it possible to get working history for multi-line commands in mksh, using vi editing mode?

On my Debian systems, I have always used pdksh as my interactive shell. Originally, command-line history behavior was similar to what I grew up with on platforms like AIX and Solaris. Recently, ...
0
votes
1answer
67 views

How to avoid executing a command if a process doesn't exist

In a korn shell script, I am running expdp. I have made the script to where it can be reusable so if a later process fails, I can run it again without running the already completed steps. I am running ...
0
votes
1answer
38 views

ksh: Not importing prompt settings from /etc/profile

I am using SUSE Linux Enterprise Server 11 SP3 and I am facing an issue related with a user using ksh. I have created a user as follows: ...
0
votes
1answer
44 views

Retrieving prompt information in ksh?

If there is a prompt being read for a value such as: #!/bin/ksh echo "What is your name?" read name username=$name rcmd machine1 grep $username /path/locnames >> namefile rcmd machine1 cat ...
3
votes
4answers
122 views

Shell usage of “:-” and advantage

I found this line in a korn shell script: var=${var:-/temp} I am able to figure it out what it is doing $ var=/data $ var=${var:-/temp} $ echo $var /data $ var= $ echo $var $ var=${var:-/temp} $ ...
4
votes
0answers
39 views

Enabling completion with tab on an old ksh on SystemV

Is it possible to make completion with Tab like in bash? Currently I use Esc twice, can this be changed to a tab?
-2
votes
1answer
81 views

How to create a script that merges two files to get a specific output in the korn shell? [duplicate]

I'm currently working on trying to merge two files together on unix and I REALLY need help. I'm very new to Unix (and this site) and would appreciate any assistance. first file: Tom 313.455.6786 ...
0
votes
1answer
41 views

KSH on old unix systemV: search history

I have set a good ksh environement on old unix PATH=$PATH:/usr/lib/acct:/usr/sbin:/sbin:/usr/ucb export PATH EDITOR=vi FCEDIT=vi export EDITOR export FCEDIT HOSTNAME=`uname -n` HISTSIZE=500 ...
0
votes
1answer
78 views

Color diff output

I am new to unix I wanted to format the unix files conditionally , I am currently working on diff command and wanted to know if it is possible to format the text of the diff command output. Example: ...
1
vote
3answers
56 views

Unix - ksh test if multiple variables are 0

So basically I want to test if 3 variables are 0. If one of them is not it should report it. This is what I got: if [[ $result -ne 0 && $resultmax -ne 0 && $resultmin -ne 0 ]] ...
2
votes
3answers
486 views

KSH/BASH Maximum size of an Array

What is the maximum size of array for ksh and bash scripting ? Example: Suppose I have an array of 10 elements than what will be maximum number of string count that a particular index of an array can ...
0
votes
0answers
41 views

KSH/BASH Comparsion b/w Two Array and then logical OR operation at other function (GNU bash 4.2 version)

I am new to unix and learning it basics. I wanted to compare same index of two different arrays and on the basis of comparision I wanted to put a data to other array. First I tried to use it ...
4
votes
3answers
428 views

KSH - if/then/else vs. double amps (&&) and double pipes (||)

I am wondering what are the best practices regarding if/then/else ; I tend to use the following form (because I find it easier to read) #!/usr/bin/ksh # [[ -f /path/to/target/file ]] && { ...
1
vote
3answers
118 views

UNIX KSH/BASH Call by Reference using Array (at GNU bash 4.2)

I am new to Unix shell scripting My code is as follows: i=0 for var in 'a' 'b' 'c' 'd' 'e' do content[i]=var ((i=`expr i+1`)) done a=10 b=50 c=40 d=90 e=100 Now I wanted to print the local ...
1
vote
1answer
90 views

KSH/bash for File Creation Dynamically

I am new to ksh and unix and I am learning it: I wanted the following:I have a directory name tmp on that directory on basis of FileName Category I wanted to create 'n' number of files dynamically. ...
1
vote
1answer
81 views

Unix Shell : Array assignment not working [duplicate]

I am new to unix shell I am learning array by following code source_array_list[0]="a" source_array_list[1]="a" source_array_list[2]="a" source_array_list[3]="a" source_array_list[4]="a" ...
1
vote
1answer
96 views

Unable to track error

I am new to Unix shell scripting, While running my program I found the following errors today.ksh[36]: test: 0403-004 Specify a parameter with this command. sed: 0602-419 Cannot find or open file ...