I'm writing a script and I would like to pass the results from bc into a variable. I've declared 2 variables (var1 and var2) and have given them values. In my script I want to pass the results from bc into another variable say var3 so that I can work with var3 for other calculations.
I want to accumulate the line size of a number of files contained in a folder. I have written the following script:
let a=0
let num=0
for i in folder/*
do
num=`cat $i | wc -l`
a=$a+$num
done
echo $a
What i am geting at the end of the script is 123+234+432+... and not the result of the arithmetic operation of addition.
Hi,
On a hosted linux environment which I have very little control over, I have a PHP script that takes in X number of floats, performs Y number of simple recursive arithmetic calculations, and produces some output for display to the user.
When I first created the script, 'X' and 'Y' were both in the single digits, and execution time wasn't really important because I was in the micro-second rang
Hi,
I am trying to execute a script (for once) during the booting time in Ubuntu system.
Googling around a bit, I found you need to divide by 1.
Hi all,
Could you please let me know how to return back the value calculated from a shell script to the main script from where its called from.
shell: KSH
example: i have two shell scripts a.sh and b.sh.
i am calling b.sh from a.sh and in b.sh suppose i calculate the word count and other calculations, How can i pass this value calculated from this b.sh script back to a.sh
example code a
Hi,
I'm trying to learn shell scriptig using bash and was trying to learn some basic arithmetic using variables. The script I am trying to write adds says z = x + y. I've been trying to use expr and the script is as follows:
Code:
x=6
y=3
z='expr x + y'
echo $z
When I run the script the return is
expr x + y
I am stuck as to why it's not running the addition and just returning the text.
Hi
I have written an email script in python which sends email to the given id.
I have customized the script for generating space alert inside a shell script as shown below
Code:
df -h /microfocus > /tmp/spacereport
## Filter the %usage to variable per
per=$(awk '{if (NR==3){print $4}}' /tmp/spacereport)
## Strip off the character % from the variable per
result=`echo $per|sed s/.$//`
Hi,
I need a shell script to determine if a no. is either even, greater than 4, less than 8
SHELL : ksh
OS : RHEL 6
this is the if block of the script
Code:
mod=`expr $num % 2`
if [ "$mod" -eq 0 ] || [ "$num" -gt 4 ] || [ "$num" -le 8 ]
then
echo "No.