DEV Community

Discussion on: Daily Challenge #1 - String Peeler

Collapse
 
v613 profile image
Ceban Dumitru • Edited

BASH

if [[ ${#1} > 2 ]]; then
    echo "${1:1:$(($#1-2))}";
else echo "not validated";
fi
Collapse
 
orenovadia profile image
orenovadia • Edited

I was surprised to find that -1 to work as well:

V=abcde
echo "${V:1:-1}"