Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

loop from array bash

#!/bin/bash
# declare an array called array and define 3 values
array=( one two three )
for i in "${array[@]}"
do
	echo $i
done
Comment

array and for loop bash

myArray=('Apple' 'Banana' 'Orange')
for i in "${myArray[@]}";
do
  echo $i
done
Comment

bash for loop string array

## declare an array variable
declare -a arr=("element1" "element2" "element3")

## now loop through the above array
for i in "${arr[@]}"
do
   echo "$i"
   # or do whatever with individual element of the array
done
Comment

bash array forloop

#!/bin/bash
## declare an array variable
declare -a array=("one" "two" "three")

# get length of an array
arraylength=${#array[@]}

# use for loop to read all values and indexes
for (( i=0; i<${arraylength}; i++ ));
do
  echo "index: $i, value: ${array[$i]}"
done
Comment

Bash script Array + For loop

month=("JAN" "FEB" "MAR" "APR" "MAY" "JUN")

for i in ${month[@]}
do
        echo -e "Month name is: c"
        echo "$i"
done
        echo
        echo -e "Total Month are: c"
        echo "${#month[@]}"
        echo
Comment

bash array and for loop

ss="abcdefghi"
my_array=( `echo $ss | grep -o . ` )

### without for loop ###########
declare -a NewArray=("${my_array[@]}")
echo ${NewArray[@]}

########### using for loop #################
for i in "${my_array[@]}"
do
     new_array+=($i)
done

for i in "${new_array[@]}"
do
	echo $i
done





Comment

PREVIOUS NEXT
Code Example
Shell :: how to change my default branch in git 
Shell :: move commit from master to branch 
Shell :: install blender on Debian Linux 
Shell :: name stash 
Shell :: github clone to local folder 
Shell :: bash if file content equals 
Shell :: docker ps not showing containers 
Shell :: how install xampp in ubuntu 
Shell :: npm install from github 
Shell :: bash memory 
Shell :: how to pull from specific branch 
Shell :: grafana speedtest 
Shell :: copy files from local to host ssh 
Shell :: install mongodb on ec2 ubuntu 18.04 
Shell :: git revert commit for single file 
Shell :: github get repo size 
Shell :: remove homebrew tap 
Shell :: cmd dir all files subfolders 
Shell :: grep word after match 
Shell :: centos monitor network traffic 
Shell :: pip install influxdb 
Shell :: PowerShell script block 
Shell :: how to get all branches from gitlab repository 
Shell :: install dpkg vscode 
Shell :: cutefish desktop enviroment install 
Shell :: bash read value 
Shell :: github clone with access token 
Shell :: how to open files using terminal in ubuntu 
Shell :: docker run --entrypoint bash 
Shell :: yarn install package 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =