The tag has no wiki summary.

learn more… | top users | synonyms

15
votes
3answers
6k views

Bash: double equals vs -eq

I am doing integer comparison in bash (trying to see if the user is running as root), and I found two different ways of doing it: Double equals: if [ $UID == 0 ] then fi -eq if [ $UID -eq 0 ] ...
2
votes
3answers
3k views

grepping a variable and adding 1 to it

I have a variable containing a leading zeroes number, and I want to grep this variable and that same variable plus one. I made several attempts but ran into errors. Here's what I want to do: read var ...
-1
votes
1answer
2k views

Sum of grep results

I need to output the sum of a grep results for a certain time, for now i hard coded the time grep but any help will be very much appreciated, my problem is i cant output the results on the script. If ...
25
votes
9answers
37k views

Is there a way to get the min, max, median, and average of a list of numbers in a single command?

I have a list of numbers in a file, one per line. How can I get the minimum, maximum, median and average values? I want to use the results in a bash script. Although my immediate situation is for ...
4
votes
2answers
3k views

In bash, how to convert 8 bytes to an unsigned int (64bit LE)?

How can I 'read/interpret' 8 bytes as an unsigned int (Little Endian)? Perhaps there is a Bash-fu magic conversion for this? UPDATE: It seems that something got cross-wired in the interpretation of ...