ksh

Shell script uses arguments from first run when run a second time

Hi all, I am operating in a Korn Shell, and attempting to run a simple chdb script I wrote. If run with no arguments, it prompts the user with a list of databases and waits for a selection. If called with a single numeric argument, it will automatically make the selection for the user. Example: > . chdb Select the database sid from ...

opening a file in aix

(AIX/ksh) i have a chinese file ...i cant able to open it in aix using cat fully...if i give cat then some contents are missing...and if i give cat -v it is giving wierd code....even i tried with while loop to read contents,but not working...with more command i can but i cant use more in shell scripting...so please shed some idea here......

printf + print lines (from ksh script) with same space between word in line

hi all I have example of the follwoing lines from print command (from ksh script) first_name=raimondelita last_name=plotanmkitus Number_id=3574553442 first_name=timratcel last_name=plotiniues Number_id=43 first_name=tom last_name=kot Number_id=564 how to print the lines (up) like this (down) with printf first_name=raimondel...

ksh-style left and right string stripping up to matched expression?

How can one strip the left parts and right parts off strings up to a matching expression as in ksh? For instance: ${name##*/} ${name%/*} (see http://www.well.ox.ac.uk/~johnb/comp/unix/ksh.html for ksh examples). I can't seem to figure out a simple way of doing this using re module or string module but I must be missing something. ...

shell script (ksh) + compare sign as param is it possible??

hi Subject shell script if I perform compare on the following [[ 2 -eq 2 ]] && print OK I get OK But how to compare if the "-eq" is in my param for example param="-eq" [[ 2 $param 2 ]] && print OK Obvious that not illegal but I wonder if it possible anyway with some changes?? Lidia ...

Storing ksh input array to variable and passing to another script

Hello - I have to modify an existing ksh script which looks at the command-line arguments using 'shift', and so empties $@, but now want to pass the original arguments to a second script afterwards. In the mainline case I can do this by coping $@ to a variable and passing that to the second script, but I can't get it to work for quoted...

Generate 12 Digit HEX number in KSH

Hi all, I need to generate 12 digit Hex numbers in KSH on Solaris Thanks ...

Linux "for" construct in ksh

I normally use the for construct in ksh to quickly iterate over a list of files to perform some action on it. It doesn't seem to work in this scenario: The file info looks like: $ ls -l tmp.* rw------- 1 op general 375 Jul 25 04:09 tmp.zzyhsg4 ... so on. Basically a lot of tmp.* files. Now when I try $ ls -lS | grep 'Jul 2...

Is there a way to have a string as a switch using getopts?

I am seeing if there is a way for getopts to handle switches with strings instead of characters. For example, I would like to supply something like this: script.ksh -file1 file1.txt -file2.txt Instead of: script.ksh -f file1.txt -g file2.txt Is this possible with unix getopts? Thanks! ...

shell script + one single syntax command in the script to send errors to log

hi all I have the test.ksh script my question if it possible to define in the first of the script that all standard errors will go to /tmp/errlog file in place to put 2>/tmp/errlog after each command etc second do not suggest the option to put the ./test.ksh 2>/tmp/errlog isn't relevant lida ...

How to go from a multiple line sed command in command line to single line in script

So I have sed running with the following argument fine if I copy and paste this into an open shell: cat test.txt | sed '/[,0-9]\{0,\}[0-9]\{1,\}[acd][0-9]\{1,\}[,0-9]\{0,\}/{N s/[,0-9]\{0,\}[0-9]\{1,\}[acd][0-9]\{1,\}[,0-9]\{0,\}\n\-\-\-//}' The problem is that when I try to move this into a korn shell script, the korn shell throws er...

How can I have term.el (ansi-term) track directories if using anyhting other than bash.

When using eshell or ansi-term and bash emacs changes the default-directory variable depending on what directory you are in. So if I move to /home/user/code/project and then use ido-find-file to open a file it starts ido with the CWD. If I use ksh (my normal shell) or zsh (tried for testing) it doesnt work. Is there a setting or is this...

How to compare versions of some products in unix shell?

Format of versions - X.X.X.X. Where X - number. What is the best way to compare two versions? I use following code: compareVersions() { VER_1=$1 VER_2=$2 print -R "$VER_1"| IFS=. read v1_1 v1_2 v1_3 v1_4 print -R "$VER_2"| IFS=. read v2_1 v2_2 v2_3 v2_4 RESULT="0" if [[ "${v1_1}" -lt "${v2_1}" ]] then RESULT="-1"...

In a unix shell, how to get yesterday's date into a variable?

Hi, I've got a shell script which does the following to store the current day's date in a variable 'dt': date "+%a %d/%m/%Y" | read dt echo ${dt} How would i go about getting yesterdays date into a variable? Basically what i'm trying to achieve is to use grep to pull all of yesterday's lines from a log file, since each line in the lo...

ksh + while loop + get the same file with the same spaces

hi dear friends need advice about the following with the following ksh script I actually copy file1 to file2 my problem is that lines in file2 are not with the same location as file1 #!/bin/ksh while read -r line ; do echo $line >> file2 done < file1 for example more file1 line1 line2 line3 more file2 lin...

ksh + print the same format as param

hi all the following script print the $line parameter my target is to print the numbers in the $line exactly as they described as the following example1 12435345645645645 6564564564565 655656565 But the script print like that 12435345645645645 6564564564565 655656565 What need to change in the script in order to get the...

cygwin : pdksh(5.2.14-3) doesn't support backslash path (\)

as an replacement for ksh under cygwin, pdksh might be the only choice. but look like there have a bug for cygwin : pdksh(5.2.14-3) to support backslash path (\). it will swallow the \ : $ cd .\access pdksh: cd: /cygdrive/e/.access - No such file or directory After search on the internet, the same problem solved for other platform. b...

ksh + smart test line solution

hi I write the following syntax (part of my ksh script) to check if the first word of LINE=star and the second word is car [[ ` echo $LINE | awk '{print $1}' ` = star ]] && [[ ` echo $LINE | awk '{print $2}' ` = car ]] && print "match" I need other simple smart and shorter solution then my syntax. from awk,perl or sed(if ...

ksh + argument in PARAM

hi is it posible to print the value NUM (100) , while I must use only ' and not " # NUM=100 # PARAM='some text $NUM' # echo $PARAM some text $value the right print some text 100 ...

shell script + match word in line without using echo

hi the following test syntax is part of ksh script [[ $PARAM = TRUE ]] && [[ ` echo $LINE_FROM_FILE | grep -c Validation ` -eq 1 ]] && print "find Validation word" Can I get some other creative syntax/solution/command to verify if Validation word exists in LINE_FROM_FILE without to use the echo command? LINE_FROM_FILE="123 Vali...