From d7df6949a7ba876de2f8a62f455ce266112b4021 Mon Sep 17 00:00:00 2001 From: khagapati-bagh Date: Fri, 1 Oct 2021 23:02:46 +0530 Subject: [PATCH] Added different style of using for loop in bash --- bash/for_loop.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 bash/for_loop.sh diff --git a/bash/for_loop.sh b/bash/for_loop.sh new file mode 100644 index 0000000..83dc762 --- /dev/null +++ b/bash/for_loop.sh @@ -0,0 +1,19 @@ +#!/bin/bash +echo "Different style of using for loop" +echo -e "\nStyle #1" +words="This is the right place to learn and sahre your skills" +for word in $words + do + echo $word + done +echo -e "\nStyle #2" +for word in Directly accessing value + do + echo $word + done +echo -e "\nStyle #3" +for ((i = 1; i <= 10; i++)) + do + echo $i | tr '\n' ' ' + done +echo -e "\n\nThank You"