unix inline script including another script


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)}'


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")

Answered By – Dominique

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published