How do I use the output of an ls command in an if statement in a bash shell [duplicate]
问题 This question already has answers here : Test whether a glob has any matches in bash (20 answers) Closed 6 months ago . I want to check if only one instance of a file exists before going on to process that file. I can check how many instances exist using this command: ls -l $INPUT_DIR/${INPUT_FILE_PREFIX}cons*.csv.gz | wc -l; However, when I go to use this within an if statement, I am warned that the ls: command not found . if [ls -l $INPUT_DIR/${INPUT_FILE_PREFIX}cons*.csv.gz | wc -l = '1']