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

0
votes
1answer
30 views

Issue passing parameters to /bin/sh -c

I am trying to use /bin/sh -c to execute a .sh script with a date parameter. The -c option is not optional as it's what the framework my team has uses. I can't get the date epoch parameter to pass ...
2
votes
4answers
74 views

How to format a bash loop using sed, awk, grep, and wc

So I have a text file that I need to get extract specific lines out of and count the number of times a number in a specific column appears. I have about 100 or so of these files. I can get it done ...
1
vote
1answer
48 views

How to organize files in main directory into smaller amount of files in sub-directories [duplicate]

I have a directory of 150 files that I wanted split into sub-directories of 25 files each: 1-25 into dir1, 26-50 into dir2, and so on. How can I accomplish this? dir1/fre_4_g2_c3654214.h3 ...
0
votes
1answer
56 views

Prepare update command using sed

I have a output file that contains 3 different column data- ['AARF'],SAMPLE12,2016-01-05 12:00:00-0500 ,529OFFST,2015-04-16 08:04:21-0400 "['EPROSP_IWS', ...
0
votes
2answers
34 views

pausing a loop in AIX to wait for user input

I'm searching for a scripting mechanism that can realize the following idea. Loop over a list and stop/wait on "read x" until the next input from a user. I know the following script is not working! As ...
-5
votes
1answer
57 views

Exit a program by pressing the key q

I have wrote a shell script in which I would like to include the functionality to exit the program by pressing the q key. Can I do that? Here is what I currently have: #!/bin/ksh echo "Press Q to ...
0
votes
1answer
28 views

Checking that $((a * b)) evaluates in my own shell [closed]

POSIX seems to define that a shell should be able to evaluate like a calculator the expression $(( a * b)) where * is a binary operator +, - or *. I programmed such a calculator for my own shell and ...
1
vote
2answers
26 views

Variable assignment in a ksh script

I am viewing a ksh script and I see a function where the variable has been defined as below. Can anyone explain what exactly the below assignment of variable means in ksh script? ...
1
vote
2answers
40 views

How to benchmark different shells [closed]

I want to know if shell 1 is better for a job than shell 2 with a test that I handle maybe with shell 3 for example ksh, dash, bash or zsh. I use a test script that builds my projects, starts it,feed ...
0
votes
3answers
49 views

sed substitution

I have a string as follows: /test/test/ 12 /test/test My goal is to turn it into: /test/est/ 12 /test/test This is the command: echo "$x" | sed 's@\(/*/\).@\1@g'" I am using at the moment but ...
-1
votes
1answer
38 views

for loop to evaluate multiple directories and execute command

I was editing a shell script and I want to know how can use for to use all directories listed by a list or variables and then execute a command. Example: I have this directories: /dirname1/app1 ...
0
votes
1answer
15 views

KSH password generator

How to make sure the generated passwords contains all these special characters: ?!/=\? Currently I'm using: pwd_usr["$i"]=`cat /dev/urandom|tr -dc "a-zA-Z0-9-_\?\!\=\/\"|fold -w 15|head -n 1` But ...
2
votes
3answers
739 views

Why can't Korn Shell do ctrl-r?

If I use PC-BSD with the default shell (Korn) then Ctrl+r doesn't work. Why won't it work? Ctrl-r was introduced to search your history in the late 1970s or early 80s and my BSD still can't do it ...
0
votes
0answers
21 views

search insert and replace [duplicate]

I want to search each record (records are defined by blank lines) in a file for the pattern NAME#AAAA. If it matches, then insert an # in front of the record's AGE line and move that line to the top ...
0
votes
0answers
16 views

I want to search for a pattern in a file. If the pattern matches, it should check for second pattern and replace it with another pattern file [duplicate]

I want to search for a pattern in a file. If the pattern matches, it should check for second pattern and replace it with another pattern INPUT FILE Name#AAAAA std 1 sec c age 5 Name#BBBB std 2 ...
0
votes
2answers
30 views

How to list files with a particular pattern created in the last 30 days in unix [duplicate]

I'm using the below command but it is not working find . PYRLLPS_GL_201610D2* -maxdepth 1 -mtime -30 I get the below error find: bad option -maxdepth find: [-H | -L] path-list predicate-list
1
vote
0answers
36 views

Following the move of the source code from the AT&T repo to Github, has anyone built ksh93, AST, or UWIN from it, on a Cygwin platform? [closed]

Following the move of the source code from the AT&T repo to Github, has anyone built ksh93, AST, or UWIN from it, on a Cygwin platform? I refer to another thread on this forum: Is the shell ...
0
votes
1answer
54 views

shell script works fine when executed in terminal, but errors out when ran as concurrent program

I'm trying to add the below string manipulation commands in my existing shell script. #!/bin/ksh y=${#text} echo "Length of text: $y" echo "Last _ is in column $((${#text} - ${#end}))" echo "Our ...
1
vote
1answer
47 views

bash or Ksh quotes and command exec [duplicate]

while creating a script I am facing currently a "strange" issue that so far I am unable to fix. typeset -r SERVICE=\"ldap://localhost:10389\ ldaps://solsrv02.internal.vbox:10689\ ...
1
vote
1answer
84 views

How to make “Ctrl + L” to clear screen in ksh under Red hat linux?

I am using putty to connect to the Red hat linux server. My shell under linux in Korn shell. I am used to clearing screen with the "Ctrl + l " combination. Some how this combination is not working ...
-1
votes
1answer
35 views

What characters are allowed in an alias?

I am confused as which are the allowed characters to be used in alias? With a function defined as f(){ echo "yes"; } Is it possible to create an alias like: alias fé='f' ### works alias ...
0
votes
1answer
42 views

Unix, create file based on command [duplicate]

I have a command, but I want to get the results into a .txt file I can open. How do I alter my command to allow the results to be put into a text file. I plan to transfer this .txt file to my local ...
3
votes
2answers
78 views

What does '-size +0' mean in shell 'test' command

I came across a if statement like this: if [ -f <file path> -size +0 ] I know that -f checks for file existed, but what does this -size +0 do here? I can't get help form man page also tried ...
1
vote
2answers
39 views

How to receive a mail whenever a file gets deleted?

I've accidentally deleted my cron using crontab - command and now the file under /var/spool/cron/crontabs directory got deleted. I would love to have a script which mails whenever my files under ...
1
vote
0answers
36 views

Conditional expressions in shell: What are the differences between [ vs [[ [duplicate]

I just wondered about some people writing if [[ <expr> ]]; then ... in answers here when I out of habit would use if [ <expr> ]; then ... Doing a quick research reveals that [[ ]] ...
5
votes
3answers
180 views

Why zsh and ksh93 chose to be non-compliant in pattern matching?

POSIX documentation for pattern matching said that: An ordinary character is a pattern that shall match itself. It can be any character in the supported character set except for NUL, those ...
1
vote
1answer
67 views

How to escape a range of wildcards in unix shell script?

I need to execute the following Oracle SQL in unix crontab. The query is as follows: select count(*) from tbaadm.htd where cust_id is not null and pstd_flg = 'Y' and del_flg = 'N' and tran_date = ...
3
votes
3answers
41 views

Assigning upper case variables to commands

While trying to decipher some scripts written by former employees of my current company, in many of the scripts, I came across the following statements which assign variables to some commands as shown ...
0
votes
1answer
28 views

Parsing a delimited in ksh as command argument

My system generates a flat file with 7 arguments : Field1,Field2,Field3,Field4,Field5,Field6,Field7 Field1,Field2,Field3,Field4,Field5,Field6,Field7 Field1,Field2,Field3,Field4,Field5,Field6,Field7 ...
1
vote
1answer
51 views

comparing decimal point values in if statement

Today I was trying to compare two values and surprised what I saw. I didn't find any good suggestion anywhere. Could any one please help? if [ 10.94 -gt 10 ] then echo True else echo False fi I ...
0
votes
0answers
15 views

Unable to print msg to console from subscript

I am calling a ksh script file from another as given below runCommand "qc_data" Here qc_data is a ksh script file. in runCommand i execute the command as below function runCommand { ...
2
votes
1answer
54 views

Two input pipes through file descriptor shuffling and /dev/fd

I want to pipe two programs into one. If my shell supports it, I can use Process substitution. For example, to list the common lines of two files in indifferent order, I can use comm -12 <(sort a) ...
0
votes
1answer
32 views

how to concatenate Login, pwd and @server variables?

how to concatenate Login, pwd and @server variables ?? ex: export Login_va="Login" export pwd_va="pwd" export server_var="@server" echo whenever sqlerror exit | sqlplus ...
1
vote
1answer
72 views

Issue with resize and stty on remote ssh script?

Scenario: Source host (Solaris 5.10, KSH), im trying to run the following script named sample.ksh on source #!/bin/ksh set -x Rediscover () { ssh user@hostB ./scripts/test.ksh } Rediscover exit 0 ...
-2
votes
1answer
51 views

KSH for generating 'n' of rows for a table dynamically : Issue with if else statement

I need to generate billion of records in a text file for table loading purpose. My destination table defination is: CREATE TABLE txnrecords12( txnno int, txndate string, custno int, ...
0
votes
4answers
37 views

Alias for listing top file and directory consumption - shortest way?

function isaix { echo "alias d='du -sm -- * 2>/dev/null | sort -nr | head -20'" >> ~/.kshrc; } function islinux { echo "alias d='du -sm -- * 2>/dev/null | sort -nr | head -20'" >> ...
0
votes
2answers
110 views

How to cut every line from a particular string?

input.txt: john_Apple01_xyz_1 john_Fruit_Apple01_abc_c1 john_Apple21_trs_1 john_Fruit_Apple21_efg_1 john_Fruit_Apple21_tefg_1 Desired output: Apple01_xyz_1 Apple01_abc_c1 Apple21_trs_1 ...
0
votes
1answer
138 views

command not found error after giving permission to access file using chmod

I've been trying to run a script using chmod. Here's how I tried to execute the script: $ chmod u+x tester $ ./tester ./tester: Command not found. I always get the Command not found error and I'm ...
1
vote
2answers
85 views

How to get the previously used command in HP-UX reverse search

I'm using HP-UX OS and want to use previously typed command, as how I'm using in Linux Ctrl+r for ease access in the HP-UX command line.
1
vote
1answer
59 views

Bash - Running a bash script from within a ksh script

I am on RHEL 6.7 and have a korn shell script that does check pre-reqs, prepares the system for rpm install's (creating directories if they are not already that are required by the product), stops ...
0
votes
1answer
40 views

cannot reload .profile from script

I am trying to reload .profile from the below script, but that doesn't work at all. #!/bin/ksh sed -i '/export rel=Rel1510_Linux/c\export rel=Rel1602_MX' ~/.profile source ~/.profile When I run ...
1
vote
1answer
42 views

Return long integer value from a function in ksh

I use the below function in ksh to return the long value of date parts function convert_date_to_long { long_date="${1}${2}${3}" return $long_date; } but the result i get is 209 when i ...
0
votes
4answers
69 views

Return value from a subscript in ksh

I want to call a script from inside a script like below weeknum=$(getweek ) Here getweek is a script file. How to write the sub script file so that it returns the value to weeknum. Should i use ...
3
votes
1answer
49 views

Opening more than 10 file descriptors with ksh

The shell syntax for opening a file for writing and using its file descriptor is: exec 3>output.log With bash and zsh you also can write: exec 13>output.log Thus, later in your script you ...
1
vote
1answer
75 views

alias su='su -' in .kshrc

I'm on OpenBSD 5.8, new to ksh and I put the string alias su='su -' in my .kshrc file as the only line. After logging in via ssh alias su gives me su alias not found and $(cat .kshrc) ...
-1
votes
1answer
78 views

How to change shell from script

I want to change shell from ksh to bash and source the .kshrc file. I want to execute following lines of command sequentially: bash . ~/.kshrc clear Can anybody help me?
1
vote
0answers
54 views

Background processes in ksh script are disappearing after they are kicked off

I'm having an issue with a KSH script that is supposed to kick off four processes in parallel in the background and then poll their status. Put simply, running the four processes sequentially would ...
1
vote
0answers
65 views

Siemens NX 10 installation: Could not determine filesystem containing /usr/ugs100

I debug script to install Siemens NX 10 applications for Debian 8.2, and get the warning: Could not determine filesystem containing /usr/ugs100 space calculations may be incorrect. The source ...
2
votes
1answer
30 views

how to differentiate error returned while reading and for EOF in shell script

I have this task of uploading a delimited file and processing it. Once the processing is done, i either say its successful and if parsing fails, i need to throw the error. I'm reading this file line ...
1
vote
2answers
300 views

cat command is not working inside shell script

I have the following line which is not working in ksh but works fine in sh cat `find /home/peter/databases -name "cells.txt"` This is working if this line is inside /usr/bin/sh script. But not when ...