linux - How to read directelly the last charachter in a string in bash? -
i have following string
string="anyanyanay"
how can read last charachter in string?
use below script
#!/bin/bash string="anyanyanay" echo ${string#${string%?}}
output : y
${string%?}
removes last character string.
${string#<character>}
removes characters
string starting.
in case
${string%?} = anyanyana
${string#${string%?}} = ${string#anyanyana} = y
Comments
Post a Comment