Skip to content

Instantly share code, notes, and snippets.

@davidalves1
Last active August 21, 2023 21:38
Show Gist options
  • Save davidalves1/189d47bca4180a07a1276cb36e3b8c68 to your computer and use it in GitHub Desktop.
Save davidalves1/189d47bca4180a07a1276cb36e3b8c68 to your computer and use it in GitHub Desktop.
Loop for all directories
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