LoginSignup
150
136

More than 5 years have passed since last update.

bashでファイルやディレクトリの存在確認方法まとめ

Posted at

よく忘れるのでまとめ

パスが存在するか
if [ -e ./test ]; then

ファイルが存在するか
if [ -f ./test ]; then

ディレクトリが存在するか
if [ -d ./test ]; then

リンクが存在するか
if [ -L ./test ]; then

空ファイルではないか
if [ -s ./test ]; then

ファイルが書込可能か
if [ -w ./test ]; then

ファイルが実行可能か
if [ -x ./test ]; then

150
136
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
150
136