Find Item in Array / Replace With Array Using Awk?
I'm trying to make my code more clean. My function seems rather oblique to do a simple find/replace. Is there a cleaner way to do this find/replace array function with awk or something similar? # Finds first item in array that matches find item, and replaces it with 1 or more array elements. # Preserves sort order of original array. find_replace_in_list(){ # $1 = list # $2 = find item string # $3 = replace array. local -n _list=$1 local -n _replace_list=$3 for i in "${!_list[@]}"; do # Iterate over indices. if [ ${_list[$i]} == "$2" ]; then # Insert the replace array starting at indice. local
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.