Initial commit
This commit is contained in:
21
snippets/sort_array.sh
Executable file
21
snippets/sort_array.sh
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
array=("a c" b f "Change" "3 5")
|
||||
IFS=$'\n' sorted=($(sort <<<"${array[*]}"))
|
||||
|
||||
echo ""
|
||||
|
||||
echo "Print out array elemnts (for loop)"
|
||||
echo "=================================="
|
||||
for val in ${sorted[@]} ; do
|
||||
echo -e "\t$val"
|
||||
done
|
||||
|
||||
echo ""
|
||||
|
||||
echo "Print out array elemnts (printf)"
|
||||
echo "================================"
|
||||
printf "\t%s\n" "${sorted[@]}"
|
||||
|
||||
echo ""
|
||||
exit
|
||||
Reference in New Issue
Block a user