Bash line to check if a file path exists using wildcards in filepath

Viewed 896

I am trying to check if a file path exists and if it does to complete the pwd command. if a file path does not exist then i want it to break and move on to the next command.

while [ -d folder1/*/stack ]; do pwd; break; done; while [<next set of commands>]...ect

i get binary operator expected error.

1 Answers

You can use ls. If ls is successfull, then pwd will run:

ls folder1/*/stack > /dev/null 2>&1 && pwd
# next command
Related