Search Results

Search: Posts Made By: nagnatar
4,362
Posted By nagnatar
for better understanding # more add.sh ...
for better understanding

# more add.sh
i=0
while read line
do
k=`expr $i + $line`
i=$k
done < num
echo "Final : ${i}"


# sh add.sh
Final : 0 -------------> Here is my...
4,362
Posted By nagnatar
Pradeep and Zedex Can you tell me which OS...
Pradeep and Zedex

Can you tell me which OS and which shell you are using?

I tested in linux, my script works well.

but found that my script does not give expected output in Sun OS 9 and 10...
4,362
Posted By nagnatar
Yes, Its working on ksh. but not on sh. any idea...
Yes, Its working on ksh. but not on sh. any idea why its not working in sh?

Thanks!
4,362
Posted By nagnatar
Pradeep, There is no blank line in "num" file.my...
Pradeep, There is no blank line in "num" file.my question is that why am not getting total sum value outside the while loop.? is it due to scope of the variable? but am getting value of the variable...
4,362
Posted By nagnatar
Here is a file "num" and its content # more num...
Here is a file "num" and its content
# more num
1
2
3
6
5
3
# more add.sh
#!/bin/sh
#set -x
i=0
while read line
do i=`expr $i + $line`
done < num
echo "Final :$i"

# ./add.sh
Final...
4,203
Posted By nagnatar
Please explain briefly what you needed
Please explain briefly what you needed
4,362
Posted By nagnatar
scope of the variable - Naga
Hi All,

I am new to unix shell scripting,
in the below script "num" is an input file which contains a series of numbers example :
2
3
5
8

I want to add the above all numbers and want...
Showing results 1 to 7 of 7

 
All times are GMT -4. The time now is 07:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy