igrek8 / if-exist

Check if file or directory exists

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Check if file or dir exists

Usage

Given that there is ./album.txt on the disk.

# Check if album.txt exists
if-exist ./album.txt && echo "album exists"

# Check if phone.txt does not exist
if-exist ./phone.txt || echo "phone does not exist"

# Create phone.txt if does not exist
if-exist -n ./phone.txt && echo "+12345" > phone.txt

About

Check if file or directory exists


Languages

Language:JavaScript 100.0%