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/bash
machine_ID="$1"
machine_number="$2"
echo "$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: 0 My expected output would be TMX 098 hours is: 1022.25
I don't know what is wrong?
Aucun commentaire:
Enregistrer un commentaire