BAEL-3132 - Linux Commands - Loop Through Directories/Folders (#7682)

* BAEL-3132 - Linux Commands - Loop Through Directories/Folders

* BAEL-3132 - Linux Commands - Loop Through Directories/Folders
- update pom description.

* BAEL-3132 - Linux Commands - Loop Through Directories/Folders
- Add another example using find exec.

* BAEL-3132 - Linux Commands - Loop Through Directories/Folders
This commit is contained in:
Jonathan Cook 2019-09-12 11:37:21 +02:00 committed by Josh Cummings
parent ec23ab367e
commit 8673e3a460
2 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,9 @@
#!/bin/bash
find . -maxdepth 1 -mindepth 1 -type d -printf '%f\n'
find . -maxdepth 1 -mindepth 1 -type d | while read dir; do
echo "$dir"
done
find . -maxdepth 1 -type d -exec echo {} \;

View File

@ -0,0 +1,11 @@
#!/bin/bash
for dir in */; do
echo "$dir"
done
for file in *; do
if [ -d "$file" ]; then
echo "$file"
fi
done