Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Working out percentage in shell script Post 302990626 by wisecracker on Sunday 29th of January 2017 02:57:27 PM
Old 01-29-2017
This should help you after reading the thread...

[awk] rounding a float number?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl script 'system' linking to local shell script not working

Trying to figure out why this works: printpwd.pl #!/usr/bin/perl use CGI::Carp qw( fatalsToBrowser ); print "Content-type: text/html\n\n"; $A = system("pwd"); $A = `pwd`; print "$A\n"; ^^actually that works/breaks if that makes any sense.. i get the working directory twice but when... (5 Replies)
Discussion started by: phpfreak
5 Replies

2. UNIX for Dummies Questions & Answers

Working out the percentage between two values

Hi there, I am totally new to Unix, I am trying to work out the percentage between two values in a ksh shell script and assign the result to a variable. Value1=577 Values2=244 So the calculation would be as follows: ((Value1 - Value2) / Value1) * 100 How would I be able to achieve... (2 Replies)
Discussion started by: NextLevelAndi
2 Replies

3. Shell Programming and Scripting

Script shell, how to calculate percentage?

hello, please can you help me. jj and kk are two numbers which are the result of an sql program. I would like to calculate the ratio jj/kk*100. I have done this: ratio=$((jj/kk * 100)) or ratio=`expr $jj \/ expr $kk) but the result is 0 What can i do? Thanks for help. (3 Replies)
Discussion started by: likeaix
3 Replies

4. Programming

Shell script to find Percentage?

Hi all, I havea log of data.log bear,10000,white bear,5000,black chicken,2000,white chicken,4000,yellow chicken,3000,black lion,6000,yellow lion,1000,white How can we have shell script to get the percentage of each animals? Thanks. (8 Replies)
Discussion started by: sabercats
8 Replies

5. Shell Programming and Scripting

expect script inside shell script not working.

Shell Scipt: temp.sh su - <$username> expect pass.exp Expect script: pass.exp #!/usr/bin/expect -f # Login ####################### expect "Password: " send "<$password>\r" it comes up with Password: but doesnt take password passed throguh file. (2 Replies)
Discussion started by: bhavesh.sapra
2 Replies

6. UNIX for Dummies Questions & Answers

Percentage / Multiplication in Shell Script

Hello, I am trying to compute the percentage in a script as shown below: PerCover=`echo "scale=2 ; 100 \* ($InputCover/$Total)" | bc` However the PerCover value is blank/null. What do I need to do differently? Thanks for your input! ~Guss (1 Reply)
Discussion started by: Gussifinknottle
1 Replies

7. Shell Programming and Scripting

Shell script not working

. /home/bscs6/.kshrc set -x monthy=`date +%m` daty=`date +%d` yeary=`date +%Y` cd /home/bscs6/scripts sqlplus sysadm/sysadm@SEGODI @lms_profile.sql mv /home/bscs6/scripts/lmsprofile.log /home/bscs6/scripts/LMS_PROFILE_DUMP_$daty$monthy$yeary.txt gives me the error below: LMS_PROFILE.sh:... (3 Replies)
Discussion started by: malefho
3 Replies

8. Shell Programming and Scripting

Cp not working in shell script but running perfectly from shell

Dear All, I have script. Dest="" IFS=' ' for translation in $(echo $MY_MAP) do t1=$(echo $translation | cut -d"=" -f1) t2=$(echo $translation | cut -d"=" -f2| cut -d"," -f1) if then Dest=$UNX/$u_product_path/$u_study_path/$UNXTR/$t2 break; ... (4 Replies)
Discussion started by: yadavricky
4 Replies

9. Shell Programming and Scripting

Working out percentage of memory utilization

Hi there I am middle of writing a script to allow me to see the % of the memory which is being used. When I submit my script I don't get any errors but I just get a blank output. Any pointers? available=`free -m | grep available` if then ... (7 Replies)
Discussion started by: simpsa27
7 Replies

10. HP-UX

Shell /awk script for Percentage

having two columns, A and B.. i need to add another column C in a file and calculate the percentage based on the column A and B. (COLUMN B/ COLUMN A *100) . "|" is delimiter separating the A and B.. need C column with the percentage value. Thanks for your help 100|50 |50% ... (6 Replies)
Discussion started by: kartikirans
6 Replies
sa1(1M) 																   sa1(1M)

NAME
sa1, sa2, sadc - system activity report package SYNOPSIS
[t n] time] time] sec] [t n] [ofile] DESCRIPTION
System activity data can be accessed at the special request of a user (see sar(1M)) and automatically on a routine basis as described here. The operating system contains a number of counters that are incremented as various system actions occur. These include CPU utilization counters, buffer usage counters, activity counters for disk, lunpath, HBA, tape I/O, and tty devices, switching and system-call counters, file-access counters, queue activity counters, and counters for inter-process communications. and shell procedures and are used to sample, save, and process this data. the data collector, samples system data n times every t seconds and writes in binary format to ofile or to standard output. If t and n are omitted, a special record is written. This facility is used at system boot time to mark the time at which the counters restart from zero. Executing the following command in a system startup script: writes the special record to the daily data file to mark the system restart. Instructions for creating system startup scripts may be found in the which is online on The shell script a variant of is used to collect and store data in binary file where dd is the current day. The arguments t and n cause records to be written n times at an interval of t seconds, or once if omitted. The following entries, if placed in produce records every 20 minutes during working hours and hourly otherwise (see cron(1M)): The shell script a variant of writes a daily report in file The options are explained in sar(1M). The following entry reports important activities hourly during the working day: Structure of the binary daily data file lists information about the active processors. The structure of the binary daily data file is: struct sa { long version[PST_MAX_CPUSTATES]; /* sadd file version */ psetid_t psetid[SAR_MAX_PROCS][2]; /* mapping of psetid and cpus in the * system */ int cpus[SAR_MAX_PROCS]; /* active processors list */ unsigned long long cpu [PST_MAX_CPUSTATES]; /* average time spent in each state */ unsigned long mp_cpu [SAR_MAX_PROCS][PST_MAX_CPUSTATES]; /* per proc cpu time */ unsigned long proc_cnt; /* MP: number of active processors */ unsigned long max_proc_cnt; /* MP: max active processors */ unsigned long bread; /* transfer of data between system * buffers and disk or other block devices */ unsigned long bwrite; unsigned long lread; /* access of system buffers */ unsigned long lwrite; unsigned long phread; /* transfer via physical device mechanism */ unsigned long phwrite; unsigned long swapin; /* number of swap transfers */ unsigned long swapout; unsigned long bswapin; /* number of 512-bytes transferred * (for bswapin:include initial loading of * some programs */ unsigned long bswapout; unsigned long pswitch; /* process switches */ unsigned long syscall; /* system calls of all types */ unsigned long sysread; /* specific system calls */ unsigned long syswrite; /* number of write() system calls */ unsigned long sysfork; /* number of fork() system calls */ unsigned long sysexec; /* number of exec() system calls */ unsigned long runque; /* run queue of processes in memory and * runable */ unsigned long runocc; /* time occurring */ unsigned long mp_runque [SAR_MAX_PROCS]; unsigned long mp_runocc [SAR_MAX_PROCS]; unsigned long swpque; /* swap queue of processes swapped */ * out but ready to run. */ unsigned long swpocc; unsigned long iget; /* use of file access system routines */ unsigned long namei; unsigned long dirblk; /* number of directory blocks encountered */ unsigned long readch; /* characters transferred by read system * calls */ unsigned long writech; /* characters transferred by write system * calls*/ unsigned long rcvint; /* receive interrupt */ unsigned long xmtint; /* transfer interrupt */ unsigned long mdmint; /* modem interrupt */ unsigned long rawch; /* input character */ unsigned long canch; /* input character processed by cannon */ unsigned long outch; /* output character */ unsigned long msg; /* message primitive */ unsigned long sema; /* semaphore primitive */ unsigned long select; /* select system calls */ unsigned int sztext; /* current size of text table */ unsigned int szinode; /* current size of inode table */ unsigned int szfile; /* current size of file table */ unsigned int szproc; /* current size of proc table */ unsigned int msztext; /* maximum size of text table */ unsigned int mszinode; /* maximum size of inode table */ unsigned int mszfile; /* maximum size of file table */ unsigned int mszproc; /* maximum size of proc table */ unsigned long inodeovf; /* cumulative overflows of inode table */ * since boot */ unsigned long fileovf; /* cumulative overflows of file table */ * since boot */ unsigned long procovf; /* cumulative overflows of proc table */ * since boot */ time_t ts; /* time stamp */ unsigned long elements_in_use; long elements[20]; }; WARNINGS
This structure can change in future releases, with no support for backward compatibility. FILES
address file daily data file daily report file SEE ALSO
timex(1), cron(1M), sar(1M), intro(7). on STANDARDS CONFORMANCE
sa1(1M)
All times are GMT -4. The time now is 01:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy