Sponsored Content
Top Forums Shell Programming and Scripting echo multiple variable with calculation Post 302503589 by alvin0618 on Friday 11th of March 2011 02:52:02 AM
Old 03-11-2011
Quote:
Originally Posted by homeboy
Code:
{
  8    echo "scale=2; $val1*100/$total" | bc
  9    echo "scale=2; $val2*100*100/$total" | bc
 10    echo "scale=2; $val3*100/$total" | bc
 11 } | tr "\n" ',' | sed 's/,$/\n/'

May i know why got curly bracket?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Display from a variable using echo.

I have a variable that is outputting a lot of space. here has been 45 lines returned ... how can I remove the spaces between the "been and the 45" CODE: fil_len=`wc -l < coshb.txt` if ; then cat coshb.txt | more echo " " echo "There has been ${fil_len} lines... (4 Replies)
Discussion started by: jagannatha
4 Replies

2. Shell Programming and Scripting

echo variable problem

hi I have say five variable. I would ask the user which one they want me to print and then print accordingly. TEST_1='10.2.3.4' TEST_2='11.2.3.5' TEST_3='12.2.3.5' TEST_4='13.2.3.5' TEST_5='14.2.3.5' print_var() { echo "Accessing var num $1" echo TEST$1 #??? But How do... (6 Replies)
Discussion started by: sabina
6 Replies

3. Shell Programming and Scripting

assigning variable value using echo

I am modifying an existing script and it has the following line: export SomeEnvVar=`echo ${SomeLocalVar}` Why wouldn't it just read: export SomeEnvVar=${SomeLocalVar} Is there some reason to use echo instead of a direct assignment? :confused: (2 Replies)
Discussion started by: shellburger
2 Replies

4. UNIX for Dummies Questions & Answers

echo multiple lines

I have a code: echo "First Line ^M Second Line" | mail -s "Lines" abc@gmail.com Basically, I want to send an email with text in this format: First Line Second Line But there is something wrong with my 'echo'. The ^M is not interpreted as carriage return. Please help. (6 Replies)
Discussion started by: laiko
6 Replies

5. Shell Programming and Scripting

Calculation in Multiple files using awk

Hi All, I have some 10 files named samp1.csv, samp2.csv,... samp10.csv Each file having the same number of fields like, Count, field1, field2, field3. And a source.csv file which has three fields field1, field2, field3. Now, i want to find the total count by taking the field1,... (8 Replies)
Discussion started by: johnwilliams.sp
8 Replies

6. Shell Programming and Scripting

Problem in echo value after some calculation

val=21 total=3250 echo "`echo "scale=2; $val*100/$total" | bc`" Output: .64 How do i show the output become "0.64" instead of ".64" ?? Someone can help? (1 Reply)
Discussion started by: alvin0618
1 Replies

7. UNIX for Dummies Questions & Answers

How to assign echo in variable

I've testing the following code: echo test.txt | cut -d . -f1and get the output "text" So why can't i assign the command to a variable? VAR='"echo test.txt | cut -d . -f1"' echo $VAR (5 Replies)
Discussion started by: jl487
5 Replies

8. Shell Programming and Scripting

echo the NAME of the variable

#!/bin/bash varA="AAA1" varB="BBB2" varC="CCC3" for proccx in $varA $varB $varC do echo "the current name is ????? , the value is $proccx" echo " " done #end of script I want the output to look something like this: the current name is varA, the value is AAA1 the current name is... (5 Replies)
Discussion started by: ajp7701
5 Replies

9. Shell Programming and Scripting

Arithmetic calculation in variable

Hi, I am trying to do an addition to a value stored in a variable... var1=`grep -n "match" sample.txt|cut -d : -f1` var2=`echo $var1|cut -d " " -f1` (Here i want add +1 to the output value) (4 Replies)
Discussion started by: Kevin Tivoli
4 Replies

10. Shell Programming and Scripting

Multiple Column Calculation

Hallo Team, I need you you help. I need to sum up all the columns in a .csv file. Lets call the file file1.csv and it looks like below: $ cat file1.csv... (2 Replies)
Discussion started by: kekanap
2 Replies
DBAR(1) 						      General Commands Manual							   DBAR(1)

NAME
dzen2-dbar - simple gadget that you can use in combination with dzen to display a progressbar. SYNOPSIS
dzen2-dbar [-w characters] [-s symbol] [-min minvalue] [-max maxvalue] [-l string] [-nonl] DESCRIPTION
dbar is an application that generates semi graphical progress meters, from some values you supply to it. See the usage examples for a description of the expected input format. OPTIONS
A summary of options is included below. -max Value to be considered 100% (default: 100) -min Value to be considered 0% (default: 0) -w Number of charcaters to be considered 100% in the bar (default: 25 ) -s Symbol represeting the percentage value in the bar (default: = ) -l label to be prepended to the bar (default: '' ) -nonl no new line, don't put '0 at the end of the bar (default: do print '0) USAGE EXAMPLES
Static 0% and 100% mark or single value input: Command: echo 25 | dbar -m 100 -l Sometext Output: Sometext 25% [====== ] If your 100% mark changes dynamically or 2-values input: Command: echo "50 150" | dbar Output: 33% [======== ] If your value range is not between [0, maxval] or 3-values input: Command: echo "50 -25 150" | dbar Output: 43% [=========== ] Dbar was written by Robert Manea. This manual page was written by bertagaz <bertagaz@ptitcanardnoir.org>, for the Debian project (but may be used by others). Jan 01 2008 DBAR(1)
All times are GMT -4. The time now is 06:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy