I am not a fan of && for series of actions, when this reads so much better and does not make for wacko indentation:
It gives you the opportunity to tell how far it ran, too.
Yes in general unless you are exploding a list, $xxx s/b "$xxx" so embedded blanks or total blankness does not invalidate what you say. I even use quotes on constants, both for a sort of parity, to tell the reader it is a constant not a variable, command or other meta-word of some sort:
BTW, any time I find myself wanting to say 'elif' anywhere, I go to 'case' not 'if'. The case operator has a nice, clear structure showing the precedence of tests and the logical 1 of all cases being addressed in the design. It provides nice opportunities to hang comments, too.
In this case, 'case' also allows you to test the $f variable without fork, exec, pipe, print or awk. Also, the if [[]] has both kinds of pattern matching native in the shell.
Either 'case', or as I suggested above, a sequence of if's that, if true, terminate the flow with exit or return. My personal term for that sort of tree collapse is 'cut them off at the pass' (prevent complexity by early pruning of odd cases like error). Putting such in some sort of script or function ensures you can leave early, as soon as you have an answer, however negative or unlikely in real life, and then proceed to the finer points of your functionality free of those worries.
Last edited by DGPickett; 11-14-2010 at 02:09 PM..
In post #25, the first two examples are wrong. In the third example the use of double quotes serves no purpose IMO, put you can use them there, as long as they are not around the part that should not be interpreted as a string.
in post 25 already i mean "double" and 'single quotes' not differ for expand ere expression..for everybody understand in this issue in ksh
and in my post #23 is related ksh93 (before my fault i mean just ksh93) and unfortunately in ksh93 we cant this expression
Hi Dears
kindly I am new here ...I want to ask your help ...
I want to write AWK command when enter date like 20140129 plus 9 then it gives me 20140207 I wrote below but the result was wrong
#!/bin/ksh
echo "please input the data:"
read a
if echo $a|awk '{if... (15 Replies)
Hi,
I have command like this with ooutput :
unix>tnsping abc
TNS Ping Utility for IBM/AIX RISC System/6000: Version 10.2.0.4.0 - Production on 17-AUG-2011 17:06:11
Copyright (c) 1997, 2007, Oracle. All rights reserved.
Used parameter files:
/opt/oracle/network/admin/sqlnet.ora
... (19 Replies)
I'm getting different behaviour when executing below script in debug option.
$ cat ss.ksh
ff=$(pwd)
echo " ff : $ff"
$ ksh ss.ksh
ff : /tmp
$ ksh -x ss.ksh
+ + pwd
ff=
+ echo ff :
ff :
I was getting this behaviour in my actuall script i'm able to reproduce this in simple script... (4 Replies)
Hi ,
What is the diffence between executing the script like
./myscript.ksh
. ./myscript.ksh
I have found 2 difference but could not find the reason
1. If i export a variable in myscript.ksh and execute it like . ./myscript.ksh the i can access the other scripts that are present in... (5 Replies)
Hi
I am new to this Scripting process and would like to know How can i write a ksh script that will call other ksh scripts and write the output to a file and/or email.
For example
-------
Script ABC
-------
a.ksh
b.ksh
c.ksh
I need to call all three scripts execute them and... (2 Replies)
Hi,
I need some help with the Ksh scripting....
I have a Script call Mail.ksh which calls Crank.ksh which calls Readdates.ksh whoch calls mindiff.ksh
the output of mindiff.ksh and Readdates.ksh are wirtten to a text file...
Here is how each file is called or executed...
./Mail.ksh 30... (3 Replies)
Ih all,
i have multiples ksh scripts for crontab's unix jobs
they all have same variables declarations and some similar functions
i would have a only single script file to declare my variables, like:
var1= "aaa"
var2= "bbb"
var3= "ccc"
...
function ab { ...}
function bc { ... }... (2 Replies)
I normally trace a script with the ksh -x <script name> and redirect strderr to file. But if you have a script like the examble below......
vi hairy
bear=`grep bear animals`
if
then
ksh more_animals
fi
If I ksh -x hairy it won't trace "more_animals" unless I put a -x in it. Is... (1 Reply)
Hi,
I'm new to unix scripting.How can i call a script from another script.
I have a.ksh and b.ksh .I have to call b.ksh from a.ksh after it is successfully exceuted.
I tried using
#!/bin/ksh -x in a.ksh and at the end i have used /path/b.ksh
My problem is it is executing only a.ksh.it... (6 Replies)