Questions tagged [math]
The math tag has no summary.
84 questions
0
votes
1
answer
38
views
`xargs sh -c` not picking up last argument (vs `for i in $(...)`) [duplicate]
I just wanted to build a simple bash script that inverted a 'hex color code' (made up of 3 pairs of 2-digit hexadecimal numbers, in the format #RRGGBB). In my first code block I attempt to perform ...
-1
votes
1
answer
73
views
Unix 'find' utility : Question about relation to Kleene Star in Mathematics
Does anyone know how the Unix find search -name queries with _? in leftmost column relate to Kleene Star as defined on Wikipedia? How can I accomplish the rows with _? using find?
. : empty ...
1
vote
1
answer
41
views
Cartesian application software recommendation in Debian [closed]
Is there a software recommendation for an application for the Cartesian field in Debian?
0
votes
2
answers
128
views
math problem or variable value problem im not sure
I am having an issue comparing epoch times. I'm really not sure what I'm doing wrong. I have been tasked with identifying and actioning files beyond and during certain date ranges.
In this case, it's ...
0
votes
3
answers
828
views
arbitrary base conversion from base 10 using only builtins in bash
I'm trying to sort out a bash command to convert a number from base 10 to an arbitrary base, using a specified set of characters (for example, to base 26 using letters a-z, although that's not ...
2
votes
1
answer
127
views
Galculator weird behavior
Why does galculator miscalculate 4000225165312/512 and gets 781293977.6?
Note This is intended as a canonical question cautioning against the unreflected use of galculator 1.2.4.
Please do not use it....
10
votes
3
answers
5k
views
Linux bc defines PI as 99
I'm using bc in Ubuntu Linux. It has a pre-defined constant PI that's set to 99.
Why does bc define PI to be 99 instead of 3.14159...?
3
votes
2
answers
26k
views
How do you type a number with a bar symbol over it?
100 divided by 3 equals 33.3 bar. How can I put a bar symbol over the three like this:
You'd think there would be 9 Unicode characters dedicated to this, but I couldn't find them.
0
votes
1
answer
337
views
How do I convert these commands to work in a conky file?
What I am doing is working on a conky widget, and I am trying to get a voltage reading from the sensor chip on my motherboard to display it. I am getting a voltage reading and displaying it in the ...
9
votes
1
answer
1k
views
Who decided the bc math library will define sine cosine and arctangent?
If you load the bc math library you get the trig functions s() and c() and a() which are sine, cosine, and arctangent respectively. Why these three functions?
I know why it's those three from the ...
0
votes
1
answer
79
views
select data conversion based on value range
I have a text file with 3 columns of data. However at random times in the various files there is a change in the in the observed unit from ppn to ppb resulting in the need of a conversion factor and ...
0
votes
1
answer
725
views
If a sum equals zero how can I get awk to print another known value to the file
I have a numerous files in which I extract the total number of records and total number of missing files in order to compute data averages. I have numerous files where the number of missing records ...
0
votes
1
answer
45
views
I have a data set with postive negative values computing LN in awk using if statement conditions
I have large datasets in where the natural log (LN) is being computed. However, there is many cases where there are negative values and awk is kicking out a warning line for each occurrence and will ...
1
vote
3
answers
745
views
Fitting a equation to a set of data
I have a set of data:
1.12158 0.42563 0.07
1.12471 0.42112 0.07
1.12784 0.41685 0.07
1.13097 0.41283 0.07
1.13409 0.40907 0.07
1.13722 0.40556 0.07
1.14035 0.40231 0.07
1.14348 0.39933 0.07
1.1466 0....
2
votes
2
answers
909
views
Does shell maths run in a subshell?
When I perform a simple math operation in #!/bin/sh, does that create a subshell?
E.g.,
addition=$(( 1 + 1 ))
The syntax would suggest a subshell, but I couldn't find anything on this
2
votes
4
answers
2k
views
How can I feed a string to awk for the purpose of mathematical calculation?
#!/bin/sh --
expression_to_evaluate='12 + 3'
printf '%s\n' "Arithemtic Expansion: $(( $expression_to_evaluate ))"
printf '%s' 'bc: '
printf '%s\n' "$expression_to_evaluate" | bc
printf '%s' 'awk: '...
1
vote
5
answers
2k
views
$@ used in a loop for math
I am trying to write a Bash script that takes a list of numbers as command line arguments and then outputs the sum of those numbers.
So the script would be run as script.sh 1 555 22 122 66 and would ...
2
votes
1
answer
5k
views
How to do math manipulation with variables in conky?
This is part of my conky code.
conky.config = {
alignment = 'top_right',
background = true,
color2 = '2ECC71',
cpu_avg_samples = 2,
default_color = 'FFFFFF',
double_buffer = ...
0
votes
1
answer
699
views
Using seq and math to manipulate the last octet in an ip address to create a file
Ubuntu 16.04
GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)
We have to add ips to servers a few times a day. I find myself creating different variations of the same file according to the ...
0
votes
1
answer
62
views
Using gawk to alter columns after a line identifier
I have multiple drawing files in the format detailed below. I need to increase the value of a number in the area of the file below after the line BO. All values (in the sample below) that are 14.00 ...
1
vote
4
answers
2k
views
Increment decimal values to next integer value
I want to increment the decimal value to next integer value through shell script.
For example:
i=**1.6** then I need to print i=**2**
i=**1.00001** then I need to print i=**2**
i=**1.00049** ...
2
votes
2
answers
548
views
primality test binary
I'm generating numbers using a Java program (BigIntegers) and I want to know if there's a binary readily available that I could use to run primality tests on the numbers generated.... suppose I feed ...
0
votes
2
answers
96
views
BASH script to catch changes to a file greater than 150MB
Need some ideas here. I was using something along the lines of
if $[$x-$y>1500]
then etc....
to detect the size of the changes to a file. I've realized that won't work as the files sizes could ...
14
votes
1
answer
1k
views
How does printf round halves to the first decimal place?
I am testing two different implementations of printf on my system: printf (GNU coreutils) 8.26, and the version bundled with zsh 5.3.1. I am testing how half numbers are rounded, i.e. for 1.5, 2.5, 3....
0
votes
1
answer
3k
views
What is the difference between bcl and expr?
I know that both of them can do simple arithmetic. I'm wondering when it will be easier to use one versus the other.
I know that expr evaluates an expression from its arguments, while bcl evaluates ...