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:
parent
ec23ab367e
commit
8673e3a460
9
linux-bash/loops/src/main/bash/find_directories.sh
Executable file
9
linux-bash/loops/src/main/bash/find_directories.sh
Executable 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 {} \;
|
11
linux-bash/loops/src/main/bash/loop_directories.sh
Executable file
11
linux-bash/loops/src/main/bash/loop_directories.sh
Executable 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
|
Loading…
x
Reference in New Issue
Block a user