I am writing a shell script that reads and reports out timestamps (the current timestamp is stored in $g2).  Eventually I will be comparing the two timestamps.
I want to check if $t2 is empty - if it is, the store it as $g2.
If not, then to replace $t2 as $t1, and store the new $g2 value as $t2.
I am trying to output this in a sudo csv style file - but when I attempt to run this script I keep getting command not found errors. Any suggestions?
if
    [[ -z "$t2" ]]
then
    $t2=$g2
    echo "$t1,0,0" >> just_time.txt
else
    $t2=$t1
    $t2=$g2
    echo "$t2,$t1,0" >> just_time.txt
fi
    
$t2= replaced by the value of t2. So you wantt2=$g2and not$t2=$g2.