Skip to content

Instantly share code, notes, and snippets.

View linuxha's full-sized avatar

Neil Cherry linuxha

View GitHub Profile
@linuxha
linuxha / array_slicing_and_compaction.advanced.bash
Created May 29, 2021 02:27
Advanced Bash :: Array slicing and compaction in bash
# Advanced Bash :: Array slicing and compaction in bash
# TL;DR
X=(something 'whatever' "i have more S P A C E S than i can give away. arent you jealous?")
# ${X[@]} the usual whole array
# ${X[@]:index:length} slice from index to index+length-1 inclusive
# ${X[@]::length} slice from 0 to length-1 inclusive
# ${X[@]:index} slice from index to end of array inclusive