Skip to content

Instantly share code, notes, and snippets.

@jwendell
Last active February 5, 2020 13:13
Show Gist options
  • Save jwendell/38ab31ece1394aa7b6e21287dfe2b146 to your computer and use it in GitHub Desktop.
Save jwendell/38ab31ece1394aa7b6e21287dfe2b146 to your computer and use it in GitHub Desktop.
#!/bin/bash
A=$(date +%Y-%m-%dT%H-%M-%S)
B=`date +%Y-%m-%dT%H-%M-%S`
while true; do
echo $A
echo $B
sleep 2
done
@sdake
Copy link

sdake commented Feb 5, 2020

move sleep from line 9 to preceed line 8. Have line 8 echo $A instead of $B.

@sdake
Copy link

sdake commented Feb 5, 2020

I made the modifications as I had suggested:

sdake@beast-01:~/go/src/istio.io/test-infra$ more jwen.sh 
#!/bin/bash

A=$(date +%Y-%m-%dT%H-%M-%S)
B=$(date +%Y-%m-%dT%H-%M-%S)

while true; do
  echo A=$A
  sleep 2
  echo B=$B
done

and the result is

sdake@beast-01:~/go/src/istio.io/test-infra$ ./jwen.sh
A=2020-02-05T06-12-15
B=2020-02-05T06-12-15
A=2020-02-05T06-12-15
B=2020-02-05T06-12-15
A=2020-02-05T06-12-15
B=2020-02-05T06-12-15
A=2020-02-05T06-12-15
B=2020-02-05T06-12-15
A=2020-02-05T06-12-15
B=2020-02-05T06-12-15
A=2020-02-05T06-12-15
B=2020-02-05T06-12-15
A=2020-02-05T06-12-15
B=2020-02-05T06-12-15
A=2020-02-05T06-12-15

which looks like $(...) is working correctly...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment