Skip to content

Instantly share code, notes, and snippets.

@shalithasuranga
Created June 2, 2022 21:32
Show Gist options
  • Save shalithasuranga/7692e265f1b566f9569386e6e55fc2b5 to your computer and use it in GitHub Desktop.
Save shalithasuranga/7692e265f1b566f9569386e6e55fc2b5 to your computer and use it in GitHub Desktop.
function get_short_name() {
short_name=''
for i in ${!fullname[@]}; do
if ((i < ${#fullname[@]} - 1)); then
short_name+="${fullname[i]::1}. "
else
short_name+=${fullname[i]}
fi
done
echo $short_name
}
read -a fullname
echo $(get_short_name $short_name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment