2

i made a linux script which receives as first argument a path to a directory. I don't know the path. And i want to check if "file.txt" exists at that certain path . For example :

if [ -e $1/file.txt ];then
       echo HAHA
fi
Claudio
  • 10,614
  • 4
  • 31
  • 71
ALex
  • 673
  • 1
  • 6
  • 19
  • 1
    `[[ -f "$1/file.txt" ]] && echo "HAHA"` should work. – anubhava Nov 22 '13 at 15:36
  • What you have should work as intended as long as `$1` doesn't contain any whitespace. Quoting it as `"$1/file.txt"` would take care of that problem. – chepner Nov 22 '13 at 17:01

1 Answers1

4
if [[ -e "$1/file.txt" ]]; then
       echo "It exists"
fi
Claudio
  • 10,614
  • 4
  • 31
  • 71