Last active
August 21, 2023 21:38
-
-
Save davidalves1/189d47bca4180a07a1276cb36e3b8c68 to your computer and use it in GitHub Desktop.
Loop for all directories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
path="/home/user" | |
for item in `ls`; | |
do | |
dir="$path/$item" | |
if [ -d $dir ] # check if it's a directory | |
then | |
cd $dir | |
pwd | |
cd .. | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment