04-23-2020
Thanks, that's what I was looking for, but how do I put the value into a variable instead of printing it with printf?
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hello
I am getting this very annoying issue in awk:
awk '{a=12825;b=a*1.25; print b}' test
16031.2
Thing is the multiplication result is wrong... Result should be 16031.25.
I think the issue only happens on bigger numbers.
What can I do to get passed this?
Thanks by advance (3 Replies)
Discussion started by: Indalecio
3 Replies
2. Shell Programming and Scripting
Hi Friends,
I am trying to round following number.
0.07435000
echo "0.07435000"|awk '{printf "%s\n",$1*100}'|awk '{printf "%.2f\n",$1}'
It returns: 7.435
It should return: 7.44
Any suggestion please?
Thanks,
Prashant (2 Replies)
Discussion started by: ppat7046
2 Replies
3. Shell Programming and Scripting
I need to read the file divide 3 column with 2nd and run a modulus of 10 and check whether the remainder is zero or not if not print the entire line.
cat filename | awk '{ if ($3 / $2 % 10 != 0) print $0}'
Whats wrong with it ? (4 Replies)
Discussion started by: dinjo_jo
4 Replies
4. Shell Programming and Scripting
Hi,
I have managed to round up numbers by using the following command:
echo "5.54" | awk '{printf "%.0f\n", $1}'
result
6
How can I round up all the numbers in a column in a file and print the lines with the new calculated totals?
Thanks, (3 Replies)
Discussion started by: keenboy100
3 Replies
5. UNIX for Advanced & Expert Users
I received error "awk: division by zero" while executing the following statement.
SunOS 5.10 Generic_142900-15 sun4us sparc FJSV,GPUZC-M
echo 8 | awk 'END {printf ("%d\n",NR/$1 + 0.5);}' file1.lst
awk: division by zero
Can someone provide solution?
Thanks
Please use code... (11 Replies)
Discussion started by: kumar77
11 Replies
6. Shell Programming and Scripting
I had a person bring an interesting problem to me that appears to involve some sort of rounding inside awk. I've verified this with awk and nawk on Solaris as well as with gawk 3.1.5 on a Linux box.
The original code fragment he brought me was thus:
for (index=0; index < 1; index=index+.1)
... (4 Replies)
Discussion started by: mmyer2
4 Replies
7. Shell Programming and Scripting
vmstat|awk '{print $3}'|tail -1
returns 6250511, but what I need is 24416, which is 6250511 divided by 256.
Please advise.
Thank you so much (2 Replies)
Discussion started by: Daniel Gate
2 Replies
8. Shell Programming and Scripting
I have some calculation in my script which is similar to the below example . I find that sometimes when using large decimal digits, the output gets automatically rounded off and it is affecting the program. I am not able to understand what is happening here..
awk '{
a=6.32498922
a1=6.324... (5 Replies)
Discussion started by: wanderingmind16
5 Replies
9. Shell Programming and Scripting
Hi Friends,
I have an input file like this
cat input
chr1 100 200 1 2
chr1 120 130 na 1
chr1 140 160 1 na
chr1 170 180 na na
chr1 190 220 0 0
chr1 220 230 nd 1
chr2 330 400 1 nd
chr2 410 450 nd nd
chr3 500 700 1 1
I want to calculate the division of 4th and 5th columns. But, if... (3 Replies)
Discussion started by: jacobs.smith
3 Replies
10. Shell Programming and Scripting
Heyas
Trying to calculate the total size of a file by reading its bitrate.
Code snippet:
fs_expected() { #
# Returns the expected filesize in bytes
#
pr_str() {
ff=$(cat $TMP.info)
d="${ff#*bitrate: }"
echo "${d%%,*}" | $AWK '{print $1}' | head -n 1
}
t_BYTERATE=$((... (9 Replies)
Discussion started by: sea
9 Replies
lpsched(1M) lpsched(1M)
NAME
lpsched, lpshut, lpmove, lpfence - start the LP request scheduler; stop the LP request scheduler; move requests between LP destinations;
define the minimum priority for printing
SYNOPSIS
requests dest
dest1 dest2
printer fence
DESCRIPTION
Schedules requests taken by
for printing on printers. is typically invoked in This creates a process which runs in the background until is executed. The
activity of the process is recorded in
recognizes the following options:
Write a verbose record of the
process on
Write logging data on
Shuts down the printer scheduler.
All printers that are printing at the time is invoked stop printing. Requests that were printing at the time the scheduler was
shut down are reprinted in their entirety after is started again. All LP commands perform their functions even when is not
running.
Moves requests that were queued by
between LP destinations.
The first form of the command moves the named requests to the LP destination, dest. requests are request IDs as returned by
The requests that are currently printing will not be moved.
The second form of the command moves all requests for destination dest1, including requests that are currently printing, to
destination dest2. As a side effect, dest1 rejects all subsequent requests.
Note that never checks the acceptance status (see accept(1M)) for the new destination when moving requests.
Defines the minimum required
priority for the spooled file to be printed. fence must be in between 0 (lowest fence) and 7 (highest fence). Each printer
has its own fence, which is initialized to 0 when it is configured by the command.
EXTERNAL INFLUENCES
Environment Variables
determines the format and contents of date and time strings.
determines the language in which messages are displayed.
If is not specified in the environment or is set to the empty string, the value of is used as a default for each unspecified or empty vari-
able. If is not specified or is set to the empty string, a default of "C" (see lang(5)) is used instead of If any internationalization
variable contains an invalid setting, the commands behave as if all internationalization variables are set to "C". See environ(5).
EXAMPLES
Move requests and from destination queues and to the destination queue if the requests are not currently printing.
Move all requests from the destination queue laserjet1 to the destination queue laserjet2. This will also cause laserjet1 to reject
all subsequent print requests to it. All currently printing requests from laserjet1 will be reprinted on laserjet2.
Suppose is a member of classes and Running this command will cause only print requests of priority 5 and above from queues and to be
printed on printer Print requests of priority 4 and below will not be picked by the scheduler for printing on
WARNINGS
and perform their operation on the local system only.
FILES
SEE ALSO
cancel(1), enable(1), lp(1), lpstat(1), accept(1M), lpadmin(1M), lpana(1M), rcancel(1M), rlp(1M), rlpdaemon(1M), rlpstat(1M).
lpsched(1M)