While loop to test if a file exists in bash

前端 未结 8 548
旧巷少年郎
旧巷少年郎 2020-12-23 10:37

I\'m working on a shell script that does certain changes on a txt file only if it does exist, however this test loop doesn\'t work, I wonder why? Thank you!



        
8条回答
  •  再見小時候
    2020-12-23 11:32

    do it like this

    while true
    do
      [ -f /tmp/list.txt ] && break
      sleep 2
    done
    ls -l /tmp/list.txt
    

提交回复
热议问题