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

前端 未结 2 567
广开言路
广开言路 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:22

    You need to separate all the arguments to test with whitespace. As it stands you have = right up against its two operands so test sees one argument, not the three that you intend.

提交回复
热议问题