From d1749b61daf4e1db39014bcd12c7c676c4cc4480 Mon Sep 17 00:00:00 2001 From: quak Date: Mon, 13 Apr 2026 09:21:45 +0200 Subject: [PATCH] (bash) adding suffix to each element of an array --- bash-test.sh | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/bash-test.sh b/bash-test.sh index 1197151..a4c051a 100755 --- a/bash-test.sh +++ b/bash-test.sh @@ -1,15 +1,11 @@ #!/usr/bin/env bash -vector=({1..20}) +array=("test0" "test1" "test2") +suffix="henlo" -echo "before : ${vector[@]}" +echo "${array[@]}" +echo "" -for n in ${!vector[@]}; do - echo $n - if (($n % 2 == 0)); then - unset vector[$n] - fi -done +array=("${array[@]/%/${suffix}}") -echo "after : ${vector[@]}" -echo "after_index : ${!vector[@]}" +echo "${array[@]}"