ksh

suppress the output to screen in shell script

别来无恙 提交于 2019-12-04 07:53:06
Hi i have written a small script: #!/usr/bin/ksh for i in *.DAT do awk 'BEGIN{OFS=FS=","}$3~/^353/{$3="353861958962"}{print}' $i >> $i_changed awk '$3~/^353/' $i_changed >> $i_353 rm -rf $i_changed done exit i tested it and its wrking fine. But it is giving the output to screen i dont need the output to screen. i simply need the final file that is made $i_353 how is it possible? Wrap the body of the script in braces and redirect to /dev/null: #!/usr/bin/ksh { for i in *.DAT do awk 'BEGIN{OFS=FS=","}$3~/^353/{$3="353861958962"}{print}' $i >> $i_changed awk '$3~/^353/' $i_changed >> $i_353 rm

Bash or KornShell (ksh)? [closed]

廉价感情. 提交于 2019-12-04 07:29:32
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 8 years ago . I am not new to *nix, however lately I have been spending a lot of time at the prompt. My question is what are the advantages of using KornShell (ksh) or Bash Shell? Where are the pitfalls of using one over the other? Looking to understand from the perspective of a user, rather than purely scripting. 回答1: Bash.

how to send a mail with a message in unix script

橙三吉。 提交于 2019-12-04 07:27:01
New to unix and learning the talk and walk of it. I am writing a script in .ksh and have a requirement of sending a mail with a message. Currently using this command in my script: mailx -s"File not found" abc@def.com This command helps me having a subject and the recipient name. My question is how can I write a message along with it. Cause every time i run the script it pauses and asks me to enter the message and then executes, I want to pre-include the message so the script would not pause in between. echo 'Message body goes here' | mail -s 'subject line goes here' email@provider.com Try this

How to implement singleton in shell script

。_饼干妹妹 提交于 2019-12-04 06:43:33
问题 In kornshell, `basename $0` gives me the name of the current script. How would I exploit $$ or $PPID to implement the singleton pattern of only having one script named `basename $0` executed on this server by any user? ps -ef|grep `basename $0` This will show me all processes which are running that have the name of the currently running script. I need a script which can abort when a thread which is not $$ is running the script named `basename $0`. 回答1: To provide a race-free mutex, flock is

How to autocomplete at the KornShell command line with the vi editor

天大地大妈咪最大 提交于 2019-12-04 05:26:46
In the KornShell (ksh) on AIX UNIX Version 5.3 with the editor mode set to vi using: set -o vi What are the key-strokes at the shell command line to autocomplete a file or directory name? paxdiablo ESC\ works fine on AIX4.2 at least. One thing I noticed is that it only autocompletes to the unique part of the file name. So if you have the files x.txt, x171go and x171stop, the following will happen: Press keys: Command line is: x x <ESC>\ x 1 x1 <ESC>\ x171 g<ESC>\ x171go Brian Deterling Extending the other answers: <ESC>* will list all matching files on the command line. Then you can use the

Put result of awk into an array

ⅰ亾dé卋堺 提交于 2019-12-04 04:21:20
问题 When I run the following command on terminal, awk /984/ $files | awk -F, '{OFS=",";print $1,$4,$17}' where, files=`ls` I get this output: 2013/08/18 12:51:37,11,724 2013/08/18 12:48:02,227,84769 I wish to create a script, run that command and assign the above result to an array in this way: (Separate lines as separate elements) array[0] = 2013/08/18 12:51:37,11,724 array[1] = 2013/08/18 12:48:02,227,84769 BUT, neither, result=($(awk /string/ $files | awk -F, '{OFS=",";print $1,$4,$17}')) nor,

How to format the date in KornShell script to DD-MON-YYYY?

不羁岁月 提交于 2019-12-04 04:04:48
问题 How do I format a date in a KornShell (ksh) script to DD-MON-YYYY? I have tried the following: date '+%d-%h-%Y' It returns 04-Nov-2009 I need for the Nov to be NOV (all caps). Can this be done with the date utility? 回答1: This is what finally worked on unix(solaris). date '+%d-%h-%Y' | tr [:lower:] [:upper:] returned: 04-NOV-2009 回答2: The ^ character forces uppercase in the GNU coreutils date (at least, it does in version 6.9.92.4 of coreutils): $ date '+%d-%^h-%Y' 04-NOV-2009 Unfortunately, ^

Is it possible to increase the maximum number of characters that ksh variable accepts?

大兔子大兔子 提交于 2019-12-04 03:48:15
问题 This is a follow up question to What is the maximum number of characters that the ksh variable accepts? I checked my environment and it's allowing only #include <sys/limits.h> $ cpp << HERE | tail -1 > #include <limits.h> > ARG_MAX > HERE 1048576 Is there a way to increase this? Or any alternatives for while read line; do #parse logic done < $filename To handle really long lines? Based from the records I'm parsing it will not stop at 2M character lines. Environment Details : AIX $ KSH Version

Why does ksh allow unpaired quotes while bash does not?

邮差的信 提交于 2019-12-04 03:38:42
When I execute following command, on bash shell I get error but on Korn shell it runs perfectly fine. The only difference is missing single quote at the end of awk, after }. Could you help me understand why? echo `echo "a b c d" | awk '{ print $1 }` In the Korn shell, both back ticks and quotes can be left unmatched, the tokenizer will try and guess where either will end and match them accordingly. Examples: /home/ufierro # echo "`echo ah" + echo ah + echo ah ah /home/ufierro # echo `echo 'hello world` + echo 'hello world' + echo hello world hello world Notice how both examples show a

Return value from a Java code

。_饼干妹妹 提交于 2019-12-03 22:30:23
There is a Java class which creates a POST request and sends it to a servlet. The main method of the class file (test) looks something like this: public static void main(String[] args) throws IOException { // Code logic goes here... // No return Statement } This is called from a KornShell (ksh) script something like this: retcode=`$CLK_JAVA_PATH -cp $CLASSPATH test ${PASSWORD} ${HOSTNAME} ${TOOLSET}` if [ $? != "0" ];then echo "ERROR: echo "${retcode}" else echo "${SCRIPT} Success" fi retcode always has the value "2" independent of if the code fails or succeeds. My question is since the return