Answers for "reverse string in shell script"

0

reverse string in shell script

#!/bin/bash
read -p "Enter string:" string
len=${#string}
for (( i=$len-1; i>=0; i-- ))
do
# "${string:$i:1}"extract single single character from string.
reverse="$reverse${string:$i:1}"
done
echo "$reverse"
Posted by: Guest on August-19-2021

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language