My question is more so a question about code efficiency and simplicity than it is about simply completing a task. The scenario is as such: I would like to create a bash script that uses a for loop to iterate through /Users when it is in each users home directory I want it to see if two different directories exist in the style of:
for USER in /Users/*; do
if [ -d "$USER/Library/Caches/com.spotify.Client" ]; then
rm -rf "$USER/Library/Caches/com.spotify.Client"
…but I need to check for multiple directories. How do I accomplish this in the most elegant way? I would like to avoid using a series of if statements but don’t know the best way to accomplish this.
Finally, I would like to use the find command to find a file, then set the result of the find (i.e. the path to the found file) to a variable and input it into another command. Thank you.
From what I understand of your requirements, I would nest the
forloops: