Wednesday, February 2, 2022

[SOLVED] unix inline script including another script

Issue

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

Solution

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
Answer Checked By - Marie Seifert (WPSolving Admin)