Home > Net >  unix inline script including another script
unix inline script including another script

Time:09-17

I have two different script 1st one is

sar -u -s 11:00:00 -e 11:10:59 | grep Average: | awk '{printf($8)}'

2nd one will show the time which is 60 min old

date -d '60 minute ago' " %H:%M:%S"

I want to use 2nd sctipt in 1st script (without creating any .sh file) Below code is not working

sar -u -s `date -d '60 minute ago' "%H:%M:%S"` -e 11:10:59 | grep Average: | awk '{printf($8)}'

CodePudding user response:

When I try this, your second command seems not to work, it should be:

date -d '60 minute ago' " %H:%M:%S"

(Mind the " " at the beginning of your format string)

When I use this, using $(...) instead of the accent graves, for readability, everything seems to be working fine:

echo $(date -d '60 minute ago' " %H:%M:%S")
  • Related