From 116d90ce2909347f35ad91999a12de09c75951b6 Mon Sep 17 00:00:00 2001 From: Jon Cook Date: Fri, 30 Aug 2019 11:54:09 +0200 Subject: [PATCH 1/4] BAEL-3132 - Linux Commands - Loop Through Directories/Folders --- linux-modules/bash/pom.xml | 18 ++++++++++++++++++ .../src/main/resources/find_directories.sh | 7 +++++++ .../src/main/resources/loop_directories.sh | 11 +++++++++++ linux-modules/pom.xml | 19 +++++++++++++++++++ 4 files changed, 55 insertions(+) create mode 100644 linux-modules/bash/pom.xml create mode 100755 linux-modules/bash/src/main/resources/find_directories.sh create mode 100755 linux-modules/bash/src/main/resources/loop_directories.sh create mode 100644 linux-modules/pom.xml diff --git a/linux-modules/bash/pom.xml b/linux-modules/bash/pom.xml new file mode 100644 index 000000000000..bb8dd675f878 --- /dev/null +++ b/linux-modules/bash/pom.xml @@ -0,0 +1,18 @@ + + + 4.0.0 + bash + 1.0-SNAPSHOT + bash + Linux Bash Topics + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + ../../ + + + diff --git a/linux-modules/bash/src/main/resources/find_directories.sh b/linux-modules/bash/src/main/resources/find_directories.sh new file mode 100755 index 000000000000..76a0a208bd1c --- /dev/null +++ b/linux-modules/bash/src/main/resources/find_directories.sh @@ -0,0 +1,7 @@ +#!/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 \ No newline at end of file diff --git a/linux-modules/bash/src/main/resources/loop_directories.sh b/linux-modules/bash/src/main/resources/loop_directories.sh new file mode 100755 index 000000000000..77e661d710fe --- /dev/null +++ b/linux-modules/bash/src/main/resources/loop_directories.sh @@ -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 \ No newline at end of file diff --git a/linux-modules/pom.xml b/linux-modules/pom.xml new file mode 100644 index 000000000000..347c9d096ed6 --- /dev/null +++ b/linux-modules/pom.xml @@ -0,0 +1,19 @@ + + + 4.0.0 + linux-modules + linux-modules + pom + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + .. + + + + bash + + From d1aa5dc4df6c5677edb4296c19748fac0e22939a Mon Sep 17 00:00:00 2001 From: Jon Cook Date: Fri, 30 Aug 2019 12:10:34 +0200 Subject: [PATCH 2/4] BAEL-3132 - Linux Commands - Loop Through Directories/Folders - update pom description. --- linux-modules/bash/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-modules/bash/pom.xml b/linux-modules/bash/pom.xml index bb8dd675f878..9694fb0d5ccb 100644 --- a/linux-modules/bash/pom.xml +++ b/linux-modules/bash/pom.xml @@ -6,7 +6,7 @@ bash 1.0-SNAPSHOT bash - Linux Bash Topics + Linux Bash Topics com.baeldung From 03b402187bbee2d975fd7ff0124e20fb59134b86 Mon Sep 17 00:00:00 2001 From: Jon Cook Date: Sun, 1 Sep 2019 13:16:59 +0200 Subject: [PATCH 3/4] BAEL-3132 - Linux Commands - Loop Through Directories/Folders - Add another example using find exec. --- linux-modules/bash/src/main/resources/find_directories.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/linux-modules/bash/src/main/resources/find_directories.sh b/linux-modules/bash/src/main/resources/find_directories.sh index 76a0a208bd1c..8a9b20294dc6 100755 --- a/linux-modules/bash/src/main/resources/find_directories.sh +++ b/linux-modules/bash/src/main/resources/find_directories.sh @@ -4,4 +4,6 @@ find . -maxdepth 1 -mindepth 1 -type d -printf '%f\n' find . -maxdepth 1 -mindepth 1 -type d | while read dir; do echo "$dir" -done \ No newline at end of file +done + +find . -maxdepth 1 -type d -exec echo {} \; \ No newline at end of file From 5c9635666f23ebdf101856892991433e5c59915e Mon Sep 17 00:00:00 2001 From: Jon Cook Date: Mon, 9 Sep 2019 17:54:08 +0200 Subject: [PATCH 4/4] BAEL-3132 - Linux Commands - Loop Through Directories/Folders --- .../loops/src/main/bash}/find_directories.sh | 0 .../loops/src/main/bash}/loop_directories.sh | 0 linux-modules/bash/pom.xml | 18 ------------------ linux-modules/pom.xml | 19 ------------------- 4 files changed, 37 deletions(-) rename {linux-modules/bash/src/main/resources => linux-bash/loops/src/main/bash}/find_directories.sh (100%) rename {linux-modules/bash/src/main/resources => linux-bash/loops/src/main/bash}/loop_directories.sh (100%) delete mode 100644 linux-modules/bash/pom.xml delete mode 100644 linux-modules/pom.xml diff --git a/linux-modules/bash/src/main/resources/find_directories.sh b/linux-bash/loops/src/main/bash/find_directories.sh similarity index 100% rename from linux-modules/bash/src/main/resources/find_directories.sh rename to linux-bash/loops/src/main/bash/find_directories.sh diff --git a/linux-modules/bash/src/main/resources/loop_directories.sh b/linux-bash/loops/src/main/bash/loop_directories.sh similarity index 100% rename from linux-modules/bash/src/main/resources/loop_directories.sh rename to linux-bash/loops/src/main/bash/loop_directories.sh diff --git a/linux-modules/bash/pom.xml b/linux-modules/bash/pom.xml deleted file mode 100644 index 9694fb0d5ccb..000000000000 --- a/linux-modules/bash/pom.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - 4.0.0 - bash - 1.0-SNAPSHOT - bash - Linux Bash Topics - - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - ../../ - - - diff --git a/linux-modules/pom.xml b/linux-modules/pom.xml deleted file mode 100644 index 347c9d096ed6..000000000000 --- a/linux-modules/pom.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - 4.0.0 - linux-modules - linux-modules - pom - - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - .. - - - - bash - -