Why is my string comparison in Bash always evaluated as true?

前端 未结 2 569
广开言路
广开言路 2021-01-18 00:32

I have a script checking if a file is up-to-minute.

updatedate=`ls -l file | sed -e \'s/  */ /g\' | cut -d\' \' -f7` #cut the modification time
nowdate=`date         


        
2条回答
  •  不知归路
    2021-01-18 01:20

    You need a space on each side of the equals sign.

    
    if [ "$updatedate" = "$nowdate" ]
    

提交回复
热议问题