dimanche 15 mars 2015

bash division of numbers in text file


I have two numbers in test.txt file, I would like a way to divide the second number by the first number and assign the result to a variable or file in a bash script that I can use. I have used awk "NR==1" test.txt to get number1 displayed on command line but inside of script, I have tried awk "NR==2" test.txt / awk "NR==1" test.txt and all of the quote / bracket combinations of such. The command line use gives num2/num1 as result, not the result of division or gives syntax error. I am using Debian Linux as OS. test.txt file contains



0250368000
0182885654


I want the second number divided by the first var=0182885654/0250368000 The numbers will change from time to time and I want a script that will process the numbers.



Aucun commentaire:

Enregistrer un commentaire