Linux file to determine whether there is a command of

The presence of file output yes, otherwise output no.

shell terminal to execute:

[ -f hello.txt ] && echo yes || echo no
  • -f 文件名字True file exists.
  • Execution [ -f hello.txt ]is true is executed echo yes, or the statement because the ||presence of echo nono longer perform.
  • In particular, where the logic and the logic or worthy of careful consideration.
Published 354 original articles · won praise 80 · Views 150,000 +

Guess you like

Origin blog.csdn.net/nicai_xiaoqinxi/article/details/103625205