Sort by

recency

|

138 Discussions

|

  • + 0 comments

    my solution

    #!/bin/bash
    declare -a array
    i=0
    #storing country names in the array
    while read -r country; do
        array[$i]=$country
        ((i++))
    done
    
    for ((j=0;j<i;j++)); do
        if [[ $j -ge 3 ]] && [[ $j -le 7 ]]; then
            echo -n "${array[$j]} "
        fi
    done | paste -sd ' '
    
  • + 0 comments

    Using mapfile:

    mapfile -n 5 -s 3 -t array
    echo "${array[@]}"
    
  • + 0 comments
    i=0
    while read input
    do
    x[$i]=$input
    i=$((i+1))
    done
    echo ${x[@]:3:5}
    
  • + 0 comments
    readarray array
    echo ${array[@]:3:5}
    
  • + 0 comments
    #!/bin/bash
    countries=()
    while read line;do
    countries+=("$line")
    done
    echo "${countries[@]:3:5}"