ksh

grep output placed into a while loop

自古美人都是妖i 提交于 2020-03-28 06:15:14
问题 I currently have my grep output configured to place everything in a file, i'm trying to set something up where a file will not need to be created. func_database () { egrep "^[0-9]" file.txt | egrep "/ON /" | sed s/-[^@]*$// > /users/home/myhome/log/test.txt } func_database while read -r line ; do echo "Database $line Area a:" python amgr.py status $line a echo "" echo "Database $line Area b:" python amgr.py status $line b echo "" echo "Database $line Area c:" python amgr.py status $line c

How to have a user select a value from array and pass that into a variable in KSH

僤鯓⒐⒋嵵緔 提交于 2020-03-06 07:23:06
问题 Overview: I would like my KSH script to test for the presence of certain files in a directory, present the user with a list of those files along with a number. The user then chooses the number they want and the relevant value from the array is assigned to a variable. So far I have the following: ### Create test files in directory #### touch ABCDEF.jar touch BCDEFG.jar touch CDEFGH.jar touch DEFGHI.jar touch EFGHIJ.jar touch FGHIJK.jar touch GHIJKL.jar set -A JARS ` ls -1 | grep .jar | cut -d'

How to have a user select a value from array and pass that into a variable in KSH

Deadly 提交于 2020-03-06 07:23:05
问题 Overview: I would like my KSH script to test for the presence of certain files in a directory, present the user with a list of those files along with a number. The user then chooses the number they want and the relevant value from the array is assigned to a variable. So far I have the following: ### Create test files in directory #### touch ABCDEF.jar touch BCDEFG.jar touch CDEFGH.jar touch DEFGHI.jar touch EFGHIJ.jar touch FGHIJK.jar touch GHIJKL.jar set -A JARS ` ls -1 | grep .jar | cut -d'

How to get epoch time in shell script (for ksh)?

不想你离开。 提交于 2020-01-17 08:13:07
问题 How to get epoch time in shell script (for ksh)? I am interested in getting epoch time for the start of day (so e.g. now is July 28th, 2011 ~ 14:25:00 EST, I need time at midnight). 回答1: If you have GNU date, epoch=$( date -d 00:00 +%s ) Otherwise, if you have tclsh, epoch=$( echo 'puts [clock scan 00:00]' | tclsh ) Otherwise, epoch=$( perl -MTime::Local -le 'print timelocal(0,0,0,(localtime)[3..8])' ) 回答2: ksh's printf '%(fmt)T' supports time calculating. For example: $ printf '%T\n' now Mon

ksh: shell script to search for a string in all files present in a directory at a regular interval

两盒软妹~` 提交于 2020-01-16 03:55:10
问题 I have a directory (output) in unix (SUN). There are two types of files created with timestamp prefix to the file name. These file are created on a regular interval of 10 minutes. e. g: 1. 20140129_170343_fail.csv (some lines are there) 2. 20140129_170343_success.csv (some lines are there) Now I have to search for a particular string in all the files present in the output directory and if the string is found in fail and success files, I have to count the number of lines present in those files

How to get the array name from a variable

女生的网名这么多〃 提交于 2020-01-15 12:22:19
问题 How to get the array name from the below ? Getting the name of the array from config : jobcfgUniqName=`echo ${config_data} | awk -F "#" '{print $3}'` Creating an array of it : for ((xx = 0; xx <= ${#joblognameSearch[@]}; xx++)) do print $joblognameSearch[$xx] eval ($jobcfgUniqName)[$xx]=`grep -B 3 -i error $joblogPath/$joblognameSearch[$xx]` print jobcfgUniqName : ${jobcfgUniqName} done This line I tried changing many ways but did not work : eval ($jobcfgUniqName)[$xx] 回答1: You can use

Bad substitution error in ksh [duplicate]

依然范特西╮ 提交于 2020-01-15 09:13:48
问题 This question already has answers here : Cannot debug simple ksh programme (2 answers) Closed 5 years ago . The following KornShell (ksh) script should check if the string is a palindrome. I am using ksh88 , not ksh93 . #!/bin/ksh strtochk="naman" ispalindrome="true" len=${#strtochk} i=0 j=$((${#strtochk} - 1)) halflen=$len/2 print $halflen while ((i < $halflen)) do if [[ ${strtochk:i:1} == ${strtochk:j:1} ]];then (i++) (j--) else ispalindrome="false" break fi done print ispalindrome But I am

Bad substitution error in ksh [duplicate]

廉价感情. 提交于 2020-01-15 09:13:22
问题 This question already has answers here : Cannot debug simple ksh programme (2 answers) Closed 5 years ago . The following KornShell (ksh) script should check if the string is a palindrome. I am using ksh88 , not ksh93 . #!/bin/ksh strtochk="naman" ispalindrome="true" len=${#strtochk} i=0 j=$((${#strtochk} - 1)) halflen=$len/2 print $halflen while ((i < $halflen)) do if [[ ${strtochk:i:1} == ${strtochk:j:1} ]];then (i++) (j--) else ispalindrome="false" break fi done print ispalindrome But I am

Bad substitution error in ksh [duplicate]

为君一笑 提交于 2020-01-15 09:12:32
问题 This question already has answers here : Cannot debug simple ksh programme (2 answers) Closed 5 years ago . The following KornShell (ksh) script should check if the string is a palindrome. I am using ksh88 , not ksh93 . #!/bin/ksh strtochk="naman" ispalindrome="true" len=${#strtochk} i=0 j=$((${#strtochk} - 1)) halflen=$len/2 print $halflen while ((i < $halflen)) do if [[ ${strtochk:i:1} == ${strtochk:j:1} ]];then (i++) (j--) else ispalindrome="false" break fi done print ispalindrome But I am

How to separate the filenames and contents matching a particular pattern in various separate files

旧时模样 提交于 2020-01-15 05:24:52
问题 I am trying to segregate filenames matching a particular into a separate file and its contents into different files matching particular patterns.I have the filenames with special characters included like '|' I tried using grep command. Grep Ril and Grep -H to print the filenames,but it is not working. #!bin/bash cd home/test let "x = 1" for file in $(find home/test/* -type f -name "*.txt") ; do var=$(echo "${x}|fill|${file##*/}") echo "${var}" | grep -n "*|fill|*.txt" >header.txt myvar=$(sed