How to check file exists via bash script?

前端 未结 2 941
轮回少年
轮回少年 2021-01-23 23:10

I\'m trying to clone a repo and test it after is done via bash script. I have written my test code based on Bash Shell: Check File Exists or Not.

#!/bin/bash

ec         


        
2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-23 23:39

    If you want to know if a file exist, you can use -f flag:

    [ -f /infer/infer/bin/infer ] && echo "Infer downloaded successfully" || echo "Something went wrong :("
    

提交回复
热议问题