I have a simple script (timeconvert.sh) that converts seconds into hh:mm:ss format and writes it to a file timeremain.out:
#!/bin/bash
#convert sec to h:m:s
secs=${1:?}
h=$(( secs / 3600 ))
m=$(( ( secs / 60 ) % 60 ))
s=$(( secs % 60 ))
printf "%02d:%02d:%02d\n" $h $m $s > timeremain.out
I am trying to get it to read a file secremain.out as the input for the script but none of the following work:
cat secremain.out | ./timeconvert.sh
./timeconvert.sh < secremain.out
Can anyone suggest the proper syntax to use or an edit to the script to read the file directly?