Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [ksh]

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.

0
votes
1answer
24 views

Ambiguous error while executing ksh file

I have created a audit.ksh file which is used to clear old "*.aud" files. But when i run this file am getting below error. The strange thing is the commands inside the file works fine while executing ...
0
votes
0answers
13 views

How to get past hour using ksh? [on hold]

I am trying to get the past hour data from txt file using ksh. can you please tell me how I can do it?
6
votes
2answers
715 views

How to produce a PS1 prompt in bash or ksh93 similar to tcsh

In tcsh, I have the default: prompt [%m:%c3] %n%# which gives prompts like: [woehler:hacking/c/hello] ajcarr% and [woehler:~] ajcarr% In other words, the current directory and up to the next ...
1
vote
1answer
37 views

Unable to find regular file with default shell as bash but works when it's ksh

We have script file FileChecker.sh where it checks whether file exists or not FileChecker.sh content: #!/bin/ksh FILE=$1 FILE2=$2 if [[ "$FILE" == "" || "$FILE2" == "" ]] ; then echo "[ERROR] ...
1
vote
2answers
83 views

script with date work on Linux but not on AIX

I wrote a script to that works fine on Linux but fails on AIX 7.2. My script uses the command date with -d. The purpose of this script is to get the last day that is not a Saturday, Sunday or a ...
-1
votes
3answers
65 views

Iterate print for each line in output

I want to print uvuveve at finish each line, for each output into while statement, as below: var1;var2;uvuveve var1;var2;uvuveve var1;var2;uvuveve var1;var2;uvuveve var1;var2;uvuveve This is my code:...
0
votes
1answer
43 views

Getting find: bad option -o -name abc -o -name xyz when perform search for *.properties excluding set of directories from search [closed]

#!/usr/bin/ksh # ***************************************************************************************** # copy_properties.sh # This script copies *.properties files from all directory excluding ...
0
votes
1answer
33 views

Assigning a variable within a while loop in shell script

I am trying to assign a variable within a while loop and the script hangs during the read statement. while read -r port 60720 60721 60722 60723 60724 here is the code: qmgrs=$($MQ_INSTALL_PATH/...
1
vote
1answer
37 views

IF statement AIX (Korn Shell Script)

I've made a script which collects info. One of the things it does is checking if a file or directory exists. If yes, it copies it to the /tmp directory. The script fails with 0403-057 Syntax ...
5
votes
3answers
947 views

Equivalent to “source” in OpenBSD?

Trying to open a python3 virtual environment I have created with python3 -m venv myVenv by doing source myVenv/bin/activate as I do in Linux, but I get ksh: source: not found which mean it is ...
0
votes
1answer
50 views

elif statement is not getting executed in unix shell script

#!/bin/ksh print -n "\nEnter the client ID : " read clientID print $clientID data=$(grep jms/erms/$clientID /export/home/a0706838/test.txt;) print "\n $data" getClientID=$(echo "$data" | awk '{...
0
votes
2answers
69 views

How could I know inside a script if stdout has been redirected for it?

I have a script in ksh; depending whether there is a redirection from the command line, I redirect the output via a exec 1>file. How can I test from inside the script itself if the command calling ...
-2
votes
2answers
35 views

use the file contents line by line and execute [closed]

file.txt servername1:DBNAME1:/u01/app servername2:DBNAME2:/u01/dbs servername3:DBNAME3:/u01/app1 I want to use above file contents line by line and execute it in shell script command1 hostname=...
-2
votes
1answer
47 views

Extract string followed by specific word/symbol

I have two lines as shown below in my input file input.txt and I need to extract claimStartDate from first line and claimEndDate from second line. <ProfessionalClaim paymentIndicator="P" ...
-1
votes
1answer
82 views

Perl script not found when executed from a different directory than the current one

I am using perl64 on Windows 10 with UWIN installed. I wrote a perl script, sv2jb.pl, which runs fine when invoked under ksh by just typing its name, and when it is in the current directory. I then ...
3
votes
2answers
77 views

A Unix AIX variable without a $ symbol?

I'm trying to debug an existing program and found an if condition without $ symbol prefixed to it. Values are: dt_val=1234 prev_dt_val=1234 If condition goes like: if [ dt_val -eq prev_dt_val ] ...
0
votes
1answer
32 views

korn shell Unable to substitute ' ' (2 quotes) with ' (single quote) in a string variable

I am trying to substitute ''2019-01-14'' to '2019-01-14' in a varible $STG. I tried various techniques echo ${STG//''/'} echo $STG | sed -e s/'\'\''/'\''/g many more none of the equations are ...
0
votes
3answers
45 views

unix awk match a string and perform delimiting

I'm checking the ping connectivity checks from a host and that would ssh to another jump host and will perform ping communication. I would like to print the successful packets pinged count using awk. ...
0
votes
2answers
46 views

Move the oldest files into a directory, source directory has more than 10,000 files constantly incoming

I am working on a command to move the x number of oldest files(FIFO) into a directory, is it better idea to pipe the "find" result into "ls" or just use the "ls" .. please suggest. ls -ltr `/bin/...
1
vote
0answers
19 views

AIX 6.1 versus AIX 7.1 strange behaviour [duplicate]

I have this logic in a ksh script on AIX 6.1 and it works fine. integer loop_count=0 integer sleep_interval=5 integer alarm_interval=60 if (( $loop_count*$sleep_interval%$alarm_interval -eq 0 )) then ...
0
votes
2answers
67 views

Extracting part of string from a file in ksh environment

I have a file that has error messages as per below rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1505) rsync error: error in rsync protocol data ...
1
vote
1answer
23 views

update params of variable ksh88 [closed]

I'm trying to update a variable: FLUX=first DATE=`date +%Y%m%d_%H_%M` justName=$FLUX DIR_LOG=$REP_LOG_TD/DDL_TABLES_LOG/$justName'_'$DATE if [ condition ] then justName=other DIR_LOG=$DIR_LOG fi ...
1
vote
1answer
116 views

Align columns evenly without “column - t”

I have an output file created from a Korn shell script. I need to align the output with spaces evenly. Unfortunately column -t is not available on AIX. Actual File: X1vir1000 x1-DFB127 ...
0
votes
1answer
80 views

How can I adapt this bash progress bar function for AIX ksh88? [closed]

I have a bash script for progress bar and I use it when I work in bash: #!/bin/bash prog() { local w=80 p=$1; shift printf -v pt "%*s" "$(( $p*$w/100 ))" "";pt=${pt// /.}; printf "\r\e[...
0
votes
2answers
30 views

How to sum value of specified column by specific date in kornshell?

I'm working in a unique validation framework that validates data. For each validation job there is a SQL job with an accompanying KSH job (kornshell). The SQL queries something in the database, and ...
2
votes
1answer
47 views

Does ksh93 support +o type options with its getopts(1) builtin?

ksh93 supports long options the same way as introduced by Sun Microsystems in Spring 2004 for getopt(3), Bourne Shell and ksh88. You may e.g. use: getopt(argc, argv, "V(version)"); to establish a ...
1
vote
0answers
26 views

ksh keybind trap

I am trying to follow this code sample http://www.kornshell.com/examples/keybind # Example from page 98 typeset -A Keytable trap 'eval "${Keytable[${.sh.edchar}]}"' KEYBD function keybind # key [...
5
votes
0answers
78 views

Correct treatment of quotes in parameter expansions

Using the default value of IFS, consider unset var set -- ${var:-"hello"} echo "$#" This prints 1 as the parameter expansion expands to the single string hello. unset var set -- "${var:-"hello"}" ...
0
votes
0answers
23 views

How to iterate pattern by other one?

I have the bellow output. I try to iterate same times the Date and Time: Month Day Year HH:MM:SS for each Application n.n string found it. =========================================================...
1
vote
0answers
51 views

ksh while loop issue

In ksh, I have a while loop that reads two files. If current line of file 1 is Y then echo the current line of file 2 into new file and if current line of file 1 is N echo the string waste in winscp. ...
-1
votes
1answer
38 views

Find Command, I want to use my variables

I have a script that creates a new directory based on User Input, and well as which directory contents it will copy over. Now here is where I am having issues, I have a find command that will replace ...
2
votes
1answer
301 views

OpenBSD - How does one set an alias?

I am running the latest OpenBSD and I cannot figure out how to set a simple alias, something along the lines of cls=clear. I've tried putting it in ~/.cshrc and in ~/.profile. I've tried: alias cls ...
-1
votes
2answers
33 views

file permission error when checking filename in ksh

I'm trying to create a checksum file. The file will have a list of files from the working directory, create cksums for each file, and drop the list of files with their cksums as MD5_<>.txt along ...
1
vote
1answer
226 views

Using korn shell to compare local and remote MD5 over sftp

I am in need of creating and checking checksums between a local file, and the remote file I just pushed. If the MD5 checks, continue, else break. This needs to be in KORN shell scripting because we ...
3
votes
1answer
52 views

How to test if IFS is unset in ksh93?

It seems easy to test if a variable is unset. I know of three ways at least: #!/bin/ksh unset var [ "$#" -gt 0 ] && var=$1 [ "${var+set}" != "${var}" ] && echo set1 || ...
2
votes
2answers
710 views

Removing characters with sed [duplicate]

I am working on AIX unix and trying to remove non-printable characters from file the data looks like Caucasian male lives in Arizona w/ fiancÃÂÃÂÃÂÃÂÃÂ in file when I view in Notepad++ using UTF-8 ...
3
votes
1answer
60 views

chfs does not work in a login ksh shell [closed]

I can't find a reason why chfs command fails in ksh (I open ssh sesion with putty). But when I run ksh or ksh93 in the shell again then it works. Any clues? # alias|grep chfs # type chfs chfs is /...
3
votes
2answers
693 views

ksh - subtract 5 minutes from current time

I need to get the date and time of the command date minus 5 mins. date: 29 Aug 2018 21:56:01 result: 29 Aug 2018 21:51:02 I tried to search on the Internet/forums but most of it involved using the -...
4
votes
2answers
938 views

Script throwing error “=: not found” [duplicate]

Consider: #!/bin/ksh db2 connect to MKTETLPS user ....... using ........ db2 "select count(*) from etl.IDM_COLLAPSE_ORG_DEE c where c.IDM_PROCESS_STEP = 'I' and priority in ( '1','2','3','4','5') ...
11
votes
4answers
903 views

How to put a string search with grep command into if statement?

I want to search multiple strings in two files. If one string is found in both files, then make something. If one string is found in only one file, then make another thing. My commands are the next: ...
0
votes
1answer
35 views

How to write in new file if are occurrences in another one?

I need to create and write in a new file based in occurrences found in another file. i.e: Occurrence found in first file then write same Occurrence in another one/new to be more specific: "File1": ...
0
votes
2answers
348 views

How can we store the output of a command as an array in Unix shell script?

I want to store the ouput of a command into an array. I tried with the below command which I got from a similar question asked here. Please find below the shell comamnds I used: #!/bin/ksh mailx -H &...
0
votes
7answers
179 views

how can I increase the performance for below code

Below is my script which is having lot of performance issue #!/usr/bin/ksh while read i do x=`echo $i |cut -d"|" -f2` rem=`expr $x % 62` echo "reminder is " $rem quo=`expr $x / 62` echo "...
0
votes
0answers
185 views

invalid char '@' in expression awk output

I have an awk command on ksh script, the command extract fields from a log file to then struct them in new one. ultimate=$(grep -oP 'Time:\K.*' $log2 | column -t | awk '{print $3,"/","'"$month"'","/",...
0
votes
1answer
233 views

Bash and Ksh background color - PS1

To change the back color my command is : PS1='\[\033[46m\]' This works fine for bash but in ksh it will but a [] in front of my server. Example : Bash : [USER@SERVER] (in color) Ksh : [][USER@...
0
votes
1answer
52 views

Need to match pattern in KSH while parsing lines from file

FILE_CENT="/etc/nsswitch.conf" if [[ $OS = 'Linux' ]]; then if [[ -e $FILE_CENT ]]; then logInfo "nsswitch.conf found in $OS, Proceeding further..." while read -r LINE do if [[ `echo $...
0
votes
0answers
16 views

how to create a array within while loop [duplicate]

I have run the below command to place values to the array the command is working fine but the array does not contain any values. k=0 sed '1d' /path/result_1.csv | while IFS=, read a b c d e f g h do ...
1
vote
0answers
26 views

Extract full function definitions

Given: $ cat test.ksh doit() { doi1() { echo doi1 "$@" } doi2() { echo doi2 "$@" } doi1 a doi2 b } doit functions doit typeset -f doit Why do I get this ...
0
votes
3answers
1k views

How may I find the most recently modified file(s)?

In a directory, I have a number of files, and I need to do something with the most recently modified file with a .txt suffix. Ideally, I'd like to do myutility "$newest" in the end, where $newest ...
2
votes
1answer
2k views

how to solve the error “arg list too long” [closed]

I am running the commnad ls -lt *$ID* this command is working find if I am running separately but with in the script it returns the below error arg list too long. The id is a unique one there is only ...