Stack Exchange Network

Stack Exchange network consists of 174 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
29 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
47 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
34 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
27 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 ...
1
vote
1answer
35 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
15 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
58 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
22 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
27 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
35 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
93 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
30 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
168 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 ...
0
votes
0answers
54 views

aix extract fields from entstat command

I was collecting the SEA adapter and its related etherchannel and Network adapters status from the enstat command below. I want to extract the fields from the below command output. ETHERNET ...
3
votes
1answer
47 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 || ...
1
vote
2answers
160 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
38 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
343 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
406 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
818 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
34 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
135 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
172 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
114 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
144 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
32 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
24 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
601 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 ...
6
votes
2answers
498 views

Are Here-Strings available in ksh88?

I wanted to extract 3 words from a variable in 3 different variables in ksh script. I used this line on ksh93 and it worked fine: read A B C <<< $line Got this error for the above command ...
0
votes
1answer
40 views

get string from file name using KSH

I have a file name like 'XXAR_CUST_INV_pt_PT_BURST.xml'. I need only "BURST" as result. note: file name can have many "_"'s (Underscores). So, I need string from last underscore and before extension "...
1
vote
1answer
68 views

Why does =~ operator give a syntax error on Solaris while comparing with a regular expression

I used this following piece of code appcount_range="^[1-$APP_COUNT]$" until [[ $APP_OPTION =~ $appcount_range ]] do echo "INVALID CHOICE! Please enter a valid option:" ...
0
votes
1answer
35 views

AIX: it takes 2 execution to see the true result

Why every time I execute my script, I tooks 2 execution before I see the true result, script_dir=/opt/scripts/x186299 smo_log=/oracle/bxcons21/base/admin/bxcons21/scripts/logs error_txt=$script_dir/...
0
votes
0answers
21 views

ksh: multiplication of variables having values with leading zeroes [duplicate]

For the below code written in ksh, phy_col=$(($bits*$mux)) if bits=40 and mux=8 then it works fine but if bits=040 and mux=08 then answer is incorrect. Any suggestions?
1
vote
1answer
41 views

Turn flushing history in ksh after each command (or stop refreshing it)

I have read that ksh, in contrary to bash, flushes its history after each command. This may be good for many, but for me, it drives me nuts! I have several windows opened that are opened for their ...
0
votes
2answers
74 views

IF-ELSE - Y|N response does not work as required

I am just finding it hard to achieve below using for-loop. Your suggestions/help will be really appreciated. Thanks If user responds in upper or lower case then it should accept and convert in ...
7
votes
3answers
1k views

How to subtract two list (fast)? [duplicate]

What is a fast way to subtract two lists1. The lists may be small, maybe a direct way in shell works. Or the lists may be long, maybe external tools are the faster way. Assume you have two lists: ...
0
votes
1answer
61 views

Parsing comma-separated digits in ksh

I have a variable in ksh that can contain no more then 2 comma-separated digits (white spaces allowed). Something like: a="1,2" a="1 ,2" a="1," a="0,0" I want a loop to read through $a exit if ...
0
votes
0answers
31 views

Unix/CGI script not fetching latest script output

I am trying to get a list of files available from a windows ftp server and then do further processing. Using CURL to get the list of file. I am getting the output displayed on browser but it is stale. ...
0
votes
0answers
24 views

Keep the section of a Unix log file following a particular string

Please see the script excerpt as below: ### TPT execution starts from here ### Arguments: TPT Script file and the login credentials echo "-------------------------------------------------------------...
1
vote
2answers
66 views

ksh - Reading an unset variable into an array using the read command [closed]

I have the following ksh script, where $an_unset_var is an unset variable which is being used for the first time: read -A arr <<< "$an_unset_var" echo ${#an_unset_var} echo ${#arr[*]} ...
0
votes
1answer
44 views

unable to spool through shell(ksh)

I've written a shell script in which i've defined variables : Last_Month,last_date and first_date and i'm trying to execute the below sql from the shell : /app/oracle/product/10.2.0/bin/sqlplus -s ...
0
votes
1answer
447 views

Exiting Shell Script from if…else

I have a shell script which I want to exit based on the value of a variable ERROR_COUNT. I can either write if [ ${ERROR_COUNT} -gt 0 ] then echo "Exiting unsuccessfully"; exit 1; fi echo "...
3
votes
1answer
68 views

How to make up arrow key display a multi-line command?

I just executed the below command in the terminal: $ while read i > do > echo $i > done 4 4 But when I tried to rerun the command using up arrow history feature, I am getting only partial ...
0
votes
1answer
519 views

Ksh script no parent error

I want the script to open a file and read the file line by line then count the number of commas per row/line. If that is more than the $2 parameter value, then write the offending line number (from ...
3
votes
1answer
62 views

Using script command for installation script on AIX

I have an installation script for my software and I need it to run on both, Linux and AIX. On Linux I can use a wrapper myinstaller.ksh like this one: #!/usr/bin/ksh script -c myrealinstaller.ksh /...
0
votes
1answer
215 views

Writing user input to file using tee

I have a script which guides users through the installation of my software and I want to write a log file in case something bad happens and the user needs support. The script looks like this: while ...
0
votes
1answer
233 views

bash script fails to run under ksh

I have below script which run successfully if i use #!/usr/bin/env bash. The same script is getting unexpected EOF while looking for matching " error while using #!/bin/ksh. Why is that? #!/usr/...