I am dumping datum into a csv file (my_datum_file.csv). The contents are all comma seperated, and I want to find the last instance of the 4th parameter (i.e. the last instance of datum regarding MX3, TMX, MSV, etc. where printed). The 5th parameter is a 'subclass' of the 4th parameter (ie TMX has 098 and 001). It is also important that the 7th parameter be status as opposed to SVlts. Q: I want the 10th value (which is a period of time in minutes) to convert to hours. I would like to print this value out.So from the terminal I wrote:$ cat /home/ed/start_up_job/my_datum_file.csv | awk -F, '( $4 == TMX ) && ( $5 == 098 ) && ( $7 == status ) {print $10/60}' | tail -1`'The end result is 1022.25 hours, which is great;I've embedded this into generic little bash script#!/bin/bashmachine_ID=$1machine_number=$2echo $1 $2 hours is `awk -F, -v MID=$machine_id -v MNR=$machine_number '( $4 == MID ) && ( $5 == MNR ) && ( $7 == status ) {t=$10} END{print int(t/60)}' /home/ed/start_up_job/my_datum_file.csv`so when I call my bash script from the terminal $ ./myscript.txt TMX 098 I get the following output TMX 098 hours is: 0My expected output would be TMX 098 hours is: 1022.25I don't know what is wrong?
Unable to print awk'ed datum in bash script
bash;terminal;csv simple;word processing
Replacing cat that was used from the terminal and with awk -F, -v MID=$machine_ID -v MNR=$machine_number '( $4 == MID ) && ( $5 == MNR ) && ( $7 == status ) {t=$10} END{print int(t/60)}' /home/ed/start_up_job/my_datum_file.csv worked. Understanding the code:awk -F defines the field seperator as ,-v assigns a value to a program variableMID=$machine_ID where as MID is the newly given variable name within awk for $machine_ID, which is a shell variable-v MNR=$machine_number similarly -v reassigns a awk variable called asMNR for a shell variable called $machine_number( $4 == MID ) equates the 4th parameter with what MID holds&& and( $5 == MNR ) equates  the 5th parameter with what MNR holds&& and( $7 == status ) equates the 7th parameter with status{t=$10} assigns the 10th value to tEND is rule that executed, once, after all the input has been readprint int(t/60) print the output of t/60 (note no $ sign infront of t) as an integer/home/ed/start_up_job/my_datum_file.csv from the file in ~Essentially, in the file /home/ed/start_up_job/my_datum_file.csv this bit of code finds the values which hold MID and MNR. Then the code places  the value of the [$]10th parameter to t and prints it as an integer after /ing by 60