I have a Bash variable, $word
, which is sometimes a word or sentence, e.g.:
word="tiger"
Or:
word="This is a sentence."
How can I make a new Bash variable which is equal to only the first letter found in the variable? E.g., the above would be:
echo $firstletter
t
Or:
echo $firstletter
T
word="tiger"
firstletter=${word:0:1}