Given a command that outputs multiple strings separated by bytes, whats the best (fastest) way to convert this into an array in bash.
eg: git ls-files -z
Given a command that outputs multiple strings separated by bytes, whats the best (fastest) way to convert this into an array in bash.
eg: git ls-files -z
For bash 4.4 and later only:
readarray -d '' array < <(git ls-files -z)
For backwards compatibility with bash 3.x and 4.0 through 4.3:
array=( )
while IFS= read -r -d '' item; do
array+=( "$item" )
done < <(git ls-files -z)