Is there a reason that you have to use expr? Can I assume that you have read the manual page for expr and digested it? It's not a nice way to users to write rules.
It seems a bit of a limitation, however you can still use the framework I suggested you can code the following in you users' personal file:-
It's messy and brackets are a problem. Notice how the multiplier * has to be coded as \*, as would the divider / needing to be \/
For numeric assignments, you might be better with bc like this:-
.... but again it's not great.
If you are allowing them to do this, can you not set the rules? If the only value they really need to put in individually is the UsrCustRegNo, then just have this in the users' my_variables file:-
.... and then do the calculation in your main script. If it is a common calculation that several scripts use, then you could have a common bit of code called in the same way in my suggested framework from before, by just adding the file name in after where the user definitions are called.
If i do below command in unix prompt which static values (ie 27..97), it is working fine and gives desired output
>ls -d $WORKDIR/batch/somefilename_{27..97}.* 2>/dev/null
somefilename_27.sometxt
somefilename_28.sometxt
somefilename_29.sometxt
..
somefilename_97.sometxt
But if i want... (2 Replies)
Hello All,
Not sure why this is happening...
When the following If Statement is evaluated for some reason it is creating a file in the CWD called '0'. I've seen this happen
before, just not in an If Statement...
CODE:
if
then
DIR_NAME="$1"
DIR_SIZE=0
STATUS=""
else... (3 Replies)
Hello All,
I'm trying to extract the lines between two consecutive elements of an array from a file.
My array looks like:
problem_arr=(PRS111 PRS213 PRS234)
j=0
while } ]
do
k=`expr $j + 1`
sed -n "/${problem_arr}/,/${problem_arr}/p" problemid.txt
---some operation goes... (11 Replies)
Hi all,
How am I read a file, find the match regular expression and overwrite to the same files.
open DESTINATION_FILE, "<tmptravl.dat" or die "tmptravl.dat";
open NEW_DESTINATION_FILE, ">new_tmptravl.dat" or die "new_tmptravl.dat";
while (<DESTINATION_FILE>)
{
# print... (1 Reply)
Hello,
Could someone explain why this one returns nothing:
$ x=/jon/
$ echo jon | awk -v xa=$x '$1~xa {print}'
$
while the following works fine:
$ x=jon
$ echo jon | awk -v xa=$x '$1==xa {print}'
$ jon
and the following works fine:
$ echo jon | awk '$1~/jon/ {print}'
$ jon
... (3 Replies)
CA_RELEASE has a value of 6. I need to check if that this is a numeric value. if not error.
source $CA_VERSION_DATA
if * ]
then
echo "CA_RELESE $CA_RELEASE is invalid"
exit -1
fi
+ source /etc/ncgl/ca_version_data
++ CA_PRODUCT_ID=samxts
++ CA_RELEASE=6
++ CA_WEEK_NO=7
++... (3 Replies)
Hi All,
I have a tcsh script as:
#!/usr/bin/csh -x
set packsName=$(awk -F'' '/^execute.*=true/{print $2}' ExecutePacks.config)
for var in $packsName
do
echo "printed $var"
done
I want to assign the value which is returned by awk function to the variable called packsName.
How do I... (2 Replies)
Hi,
I am trying to do a percentage calculation in a Bourne shell script. The following works fine, but when I try to subsitute the values 153824 and 246000 for variables (e.g. used and limit), I get errors.
calc()
{
awk 'BEGIN {OFMT="%f"; print '"$*"'; exit}'
}
calc '(153824 /... (3 Replies)
Is it possible to combine a regular expression with a aritmetical expression? For example, taking a 8-numbers caracter sequece and casting each output of a grep, comparing to a constant.
THX! (2 Replies)