Questions tagged [ksh]

The KornShell is an open source, POSIX-compatible shell language from AT&T based upon the original Bourne shell. Make sure you know whether your ksh is ksh93 or a clone.

ksh
Filter by
Sorted by
Tagged with
-3 votes
1 answer
32 views

Linux split file [closed]

I have a file output.txt that contains:- serverA start of text serverA some more text serverA end of text serverB start of text serverB some more text serverB end of text I would like to create ...
steve ecott's user avatar
0 votes
1 answer
1k views

execute a shell script against a list of arguments from the terminal

occasionally, but not often enough to need to write a script for it, i may need to run 'foo' against a set of arguments. It may vary which argument is static vs which is a list, and it may vary the ...
cheechi's user avatar
  • 55
2 votes
3 answers
371 views

need help on unix Script to read a data from specific position and use the extracted in query

Input file: ADSDWETTYT017775227ACG ADSDWETTYT029635225HCG ADSDWETTYC018525223JCG ADSDWETTYC987415221ACG ADSDWETTCC891235219ACG ADSDWETTTT074565217ACG ADSDWETTYT567895213ACG ADSDWETTYH037535215ACG ...
jcrshankar's user avatar
  • 1,157
0 votes
2 answers
147 views

ksh cmd one-liner to grep for several PIDs at once

I got a bunch of processes that I need to check CPU affinity for, so I got this one liner: for i in `ps -Fae | grep proc_name| awk '{print $2}'`; do taskset -acp $i;done but I have a problem, taskset ...
D.Zou's user avatar
  • 784
1 vote
2 answers
232 views

Printing SQL Query in unix

I need to run SQL Query in unix and print the output. After running, output printed differently. My code: i_dept=30 emp_list=`sqlplus -s SCOTT/tiger@//YourIP:1521/orcl <<END set pagesize 0 ...
Ajith Muthukumaran's user avatar
2 votes
2 answers
118 views

Quotes and slashes surviving multiple layers

Goal I need to effectively run a copy (cp) command but have explicit quote symbols preserved. This is needed so that the z/OS Unix System Services Korn shell properly recognizes the target of the copy ...
Woodsman's user avatar
  • 1,027
0 votes
3 answers
48 views

Trying to get specific field from read in Ksh

I am trying to write a simple script in Ksh to look at failed attempts and look at the ip addresses. I am dumping a lastb output to a file and want to get just the username tried and the ip address it ...
JAYCO Cloud's user avatar
0 votes
1 answer
245 views

How to reference a file for variables using ksh?

How do I reference a variable from another file using ksh? I know in bash you just use "source script" and then "echo $variable" but in ksh, when I try that, it does not work. ...
YuanL's user avatar
  • 67
0 votes
0 answers
156 views

loading data from external stage - passing stage name to a parameter

I'm using snowsql in a ksh script which loading data from a named external stage to snowflake table. My ksh snowsql -c $CONNECT -w $WAREHOUSE -s $SCHEMA -d $DATABASE \ --filename "...
Hannah's user avatar
  • 73
0 votes
1 answer
227 views

AIX Korn Shell - compare date in yyyyMM format

I'm searching for compare two date in AIX. This is the first date in yyyyMM format: three_months_ago=$(( $(date +%Y%m) - 3)) And I get the second date from filesystem with concatenation of folder ...
Micheal Bolton's user avatar
-1 votes
1 answer
96 views

What does `grep -E "xyz\.(.+)\.abc"` do in korn shell?

I have seen this piece of code in a ksh script. Wondering what it does? grep -E "xyz\.(.+)\.abc"
codethirst's user avatar
1 vote
0 answers
452 views

loading data from external stage - check if file exists before loading

I'm using snowsql in a ksh script which loading data from a named external stage to snowflake table. I want to check if a file exists before loading: if no files there, I'd like to exit without doing ...
Hannah's user avatar
  • 73
0 votes
2 answers
39 views

ksh: Replacing a word with asterisks causes bad substitution error

I'm trying replace a specific word read from a file with asterisks of the same length. Eg; cat -> *** snake -> ***** So, in my script below, it works in bash but not in ksh for next in `cat $...
cklway's user avatar
  • 3
0 votes
0 answers
222 views

"read: -a: unknown option" when running script with ksh

Hello i was able to run one of the script from putty terminal without any issue as follows sh file_validation_generic.sh 1 /test/data/infa_shared/dev/scripts but when i try to execute the script ...
daturm girl's user avatar
1 vote
1 answer
77 views

How to write .csv from another .csv in Bash or Ksh

I have a lot of output's from my matlab in .csv. I would like to put them together in one output.csv file. So my idea was use my .csv created by Matlab as variables for my output.csv global. #!/bin/...
Marcos Vinícius Gomes's user avatar
0 votes
1 answer
79 views

How to change large count of .pdf to .PDF files in AIX terminal

I have a bunch of file with the extension '.pdf' but for further processing, I need them to be in '.PDF' The method I am using is copying all the file to a notepad and them putting 'mv' in front of it ...
Shivams334's user avatar
0 votes
3 answers
284 views

how to add zero to single digit date in a date field in shell

I have data like the below 1213231421312131|USER|21121|1231412|XEM|NAME|NAME|||5072020|2313||||NY|2131|||99|E|||ver.01 6454242352352352|USER|13131|7342422|XEM|NAME|NAME|||13032001|1231||||TX|7312|||11|...
Yum.Vee's user avatar
  • 41
0 votes
1 answer
163 views

Getting ksh: NF: not found on executing ssh command

My below command throwing error like : ksh: NF: not found. sshpass -p 'pass' ssh -o StrictHostKeyChecking=no user awk -v columnCount=64 -F '\\|' 'NF && NR > 1 && NR < 12058 &...
kaviya .P's user avatar
  • 479
3 votes
4 answers
349 views

ksh's vi-mode sometimes corrupts the edit line - new version on GitHub fixes it

ORIGINAL ISSUE: I noticed that sometimes when trying to edit a line in the history to re-run a command, that ksh would garble the line and move the cursor up a line. It was really bizarre. first ...
David H's user avatar
  • 41.2k
0 votes
0 answers
100 views

How to use a column value as part of the file name created from a table using a unix ksh script

I have a Unix ksh script that creates a file from a Snowflake table. I need to use the value in one of the columns in this table (same value for all rows) in the generated file name. Instead of this......
Speedy's user avatar
  • 75
0 votes
1 answer
39 views

How to Include Variables in a File Name used in a Variable $File Equals

Why does the echo not return - /lsf10/monitors/lpstat_email_1_vmobius_05122021.txt ? It returns --> the $FILE #!/usr/bin/ksh integer max=3 integer i=1 while [[ $i -lt $max ]] do today=`date +%m%d%Y`...
Configueroa's user avatar
0 votes
1 answer
29 views

Indefinitely Looping ? Check Two Printers if Online or Offline - Send Email if Down

I have this script that is looping indefinitely - there are two printers to check once each - printer01 and printer02. If they are DOWN or OFF then send an email. Why is it looping indefinitely on ...
Configueroa's user avatar
0 votes
1 answer
2k views

Why does find command in if return "paths must precede expression" error?

Below is my ksh script. I am getting paths must precede expression error for the first if test condition. To check if I have the correct syntax for if..find, I added the second section and I ...
maskeerr's user avatar
  • 109
1 vote
1 answer
661 views

error script_name.sh: line 13: [[0: command not found

Good morning ! trying to execute this code but i have an error on if statement . error message : error script_name.sh: line 6: [[0: command not found the problèm is on "if" statement. help ...
Student's user avatar
  • 57
0 votes
1 answer
28 views

linux korn shell /../.envfile [a]..[b]..[c] meaning

I get an error message when logging in that is similar to below: Can someone please help me understanding the numbers in brackets ? In case these are some line numbers in referenced files, how to ...
user avatar
0 votes
0 answers
53 views

How I can add subscript in main script so that subscript will copy in the folder created by mainscript?

I have main.ksh script and subscript.ksh. How I can add subscript in main script so that subscript will copy in the folder created by mainscript. Main script is running through Jenkins and Crete ...
rimi's user avatar
  • 1
0 votes
0 answers
22 views

Find multiple file formats in IF condition in Shell Script [duplicate]

I would like to search a directory (should search only in that directory and shouldn't search in the recursive manner by searching inside the sub directories) with multiple file formats and even if ...
prabu's user avatar
  • 19
0 votes
2 answers
504 views

Using find command to grab the file extensions in directory in shell script [duplicate]

So far I have tried extension=$(find /home/path-to-dir -type f -name '*.*' | sed 's/^.*\.//' | sort -u) It is giving me extension right after . but it is failing for text.data.json ( I only need ...
chris evans's user avatar
0 votes
0 answers
72 views

Variable displaying single quote when trying to escape double quotes

I have the following script. #!/apps/queue/bin/ksh93 set -x OPTIONS="test \"select * from testoptions\"" mytest "${OPTIONS}" On executing the ...
Biker Boy's user avatar
0 votes
1 answer
146 views

Adding Current Date and Time in AWK pattern match with Wildcard

I have this logging string that I want to search for: [Nov 18, 2019 8:53:36 AM] ProcessFlow RMI Server started at: 10.155.166.24:16003 I want to trap the month day, year and the string "RMI ...
Configueroa's user avatar
0 votes
1 answer
331 views

Trying to replace a value with a string containing backslash \ in a file

I could really use your help here. What I want to do : I have an encrypted password I want to write in a property file. Let's say I have this password stored in $password and I want to write it as ...
Théo LM's user avatar
1 vote
1 answer
329 views

ksh93 date calculation using builtin printf function

I need to do date calculations in a shell script. Unfortunately my operating system (SunOS) does not provide a very handy date function: it does not support the -d option which is exactly what I need. ...
nico's user avatar
  • 127
0 votes
1 answer
26 views

test command doesn't run in Crontab

In Ksh shell, my below command runs okay. test "$(($(date +%W)%4))" -eq 2 && echo "yes" > /u/crmprod/test but it doesn't run in crontab using below. How to solve this ...
ddss12's user avatar
  • 99
0 votes
1 answer
73 views

How to replace date -d from script running on Linux to get it working on AIX

On a Linux system I'm running a bash script what is running fine, but now I want to use the same script on an AIX system. Only a small part of it isn't able to run because on the AIX system the ...
fabje's user avatar
  • 29
0 votes
2 answers
1k views

awk $4 column if column = value with characters thereafter

I have a file with the following data within for example: 20 V 70000003d120f88 1 2 20 V 70000003d120f88 2 2 20x00 V ...
Christopher Karsten's user avatar
0 votes
1 answer
29 views

my shell variable in if statement which is inside of while loop

I have below while loop which reads a file line by line for error codes, if this error code found in log.txt file, then I need to set alert=1 and then those errors are to be written a shell variable ...
RamReddy's user avatar
1 vote
0 answers
683 views

Pass variables from shell script to Perl script

I'm trying to send two values from my existing shell code to a Perl script, which needs to be processed. I'm relatively new to perl, and I tried accepting them using the ARGV[0] and ARGV[1], but when ...
Pv66's user avatar
  • 145
0 votes
4 answers
545 views

Shell script to sum columns associated with a name

I have a file with thousands of numbers on column 1 and each sequence of these numbers are associated with a single person. Would someone have any idea on how can I create a shell script to sum column ...
V3NT0's user avatar
  • 35
-1 votes
2 answers
884 views

Linux - How to replace the last few characters of a file name with a string

I have list of files and each file name ends with (+1) and I want to replace that (+1) of the filename with date Ex: ABC.DEF(+1) Looking for a simple solution which replaces the file name as below: ...
user2496132's user avatar
-1 votes
3 answers
66 views

ksh remote function calling another remote function2

I am having problem to run simple code below: #!/bin/ksh set -x function test_me { set -x date } function check_me { set -x ssh ${HST2} "$(typeset -f test_me); test_me" } ssh ${HST1} &...
rman oracle's user avatar
1 vote
0 answers
136 views

Proper way to store environment variables for cron jobs

We have a few ksh scripts, running as user cron jobs on RHEL7. user is set with /sbin/nologin. What is the proper way to export environment variables so it is available to the ksh script running from ...
Setec Astronomy's user avatar
0 votes
0 answers
19 views

Checking a file or directory (with spaces) exists in ksh [duplicate]

I have to delete list of directories. The list is being read from a text file. The absolute path of the directory might contain spaces as well. Here is what I am doing... while read line # Each line ...
NJMR's user avatar
  • 1,896
0 votes
2 answers
207 views

Check IP address off a list using ksh/bash

I have a list (text file) with the following data: app1 example1.google.com app2 example2.google.com dev1 device1.google.com cell1 iphone1.google.com I want to check the ip address of the URLs/...
Hansilog's user avatar
0 votes
1 answer
80 views

Unix Resolve sequence of variables stored in file

Given is a file named job.properties with below contents version=current rootDir=/a/b/c/repo appPath=${rootDir}/${version} workflowPath=${appPath}/workflow/test oozie.wf.application.path=${...
Rohit's user avatar
  • 11
0 votes
2 answers
44 views

Rename file as per fixed patter in UNIX

I have these files in mydir: APPLE_STORE_iphone12.csv APPLE_STORE_iphonex.csv APPLE_STORE_ipad.csv APPLE_STORE_imac.csv Need to rename the files after a matching pattern "APPLE_STORE_". ...
Novice_Techie's user avatar
0 votes
1 answer
44 views

How does less than operator behave differently from -le in BASH? [duplicate]

#!/bin/bash a=10 b=30 [ $a -eq $b ] echo $? echo $(($a==$b)) This code outputs 1 then 0. Why does $(($a==$b)) output 0? I have tried this with -le and < also . [ $a -le $b ] ouputs 0 $(($a < ...
Harshit Chepe's user avatar
0 votes
0 answers
15 views

substring in string shell script from last character [duplicate]

i have a text like this : 'jdbc:oracle:thin:@111.11.11.111:1521/DDEV' How can i get from last characters to 1.th "/" of text using shell script? So i need to use "DDEV" Regards
aetl's user avatar
  • 1
0 votes
0 answers
240 views

Getting exit code from SSH command running in background in Linux (Ksh script)

I trying to run few commands to be executed in parallel in couple of remote servers using SSH and i need to get the correct exit code from those commands but with no success. I am using the command ...
Carlos Andre Cardoso's user avatar
1 vote
1 answer
447 views

/usr/xpg4/bin/grep -q [^0-9] does not always work as expected

I have a Unix ksh script that has been in daily use for years (kicked off at night by the crontab). Recently one function in the script is behaving erratically as never happened before. I tried ...
newman's user avatar
  • 97
0 votes
1 answer
164 views

Insert file content (with white line and special characters ) in bash variable for insert in oracle table with sqlplus

I write this simpe test.ksh scipt: #!/bin/ksh TEST=$(cat $1 ) sqlplus -S *****/*****@*****<<- EOF set define off; SET SQLBLANKLINES ON; INSERT INTO DBADOC.TEST ( "TEST" ) ...
Michele M's user avatar
  • 147

1 2 3
4
5
56