How can I check if a given file is in a directory, including any directories with that directory, and so on? I want to do a small sanity check in a bash script to check that the user isn’t trying to alter a file outside the project directory.
Share
Use find (it searches recursively from the cwd or in the supplied directory path):
Example of using this as part of a bash script: