Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

array and for loop bash

myArray=('Apple' 'Banana' 'Orange')
for i in "${myArray[@]}";
do
  echo $i
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 :: ubuntu remove application icon 
Shell :: install netbeans 8.2 in kali linux 
Shell :: ver particiones montadas linux 
Shell :: regex match + n lines 
Shell :: sourcetree permission denied (publickey) github mac 
Shell :: git checkout branch 
Shell :: how to create new branch 
Shell :: how to execute a bash script in terminal 
Shell :: bash script comment 
Shell :: add anaconda to git bash 
Shell :: install git bash windows 10 
Shell :: wp cli plugin install 
Shell :: laptop slow performance linux ubuntu 
Shell :: rsync ssh 
Shell :: yarn add global 
Shell :: github add all files/directories and subdirectories 
Shell :: putty ubuntu 
Shell :: rails all path 
Shell :: how to delete a folder in github 
Shell :: remove directory and contents linux 
Shell :: install vault 
Shell :: how to make NTFS read only file system writable in linux 
Shell :: command prompt flashes and closes 
Shell :: open folder from terminal 
Shell :: npm install latest available packages 
Shell :: bash two for loops 
Shell :: how to delete all history for specific search term in chrome 
Shell :: enable option in ubuntu to create document on right click 
Shell :: linux ping latency print on screen .sh file 
Shell :: adobe reader for ubuntu 20.04 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =