Also awk – use slash as separator and print last field
echo "/gas/string" | awk -F/ '{print $NF}'
Or cut – but that will only work if you have same number of directories to strip
echo "/gasg/string" |cut -d/ -f 3
Also awk – use slash as separator and print last field
echo "/gas/string" | awk -F/ '{print $NF}'
Or cut – but that will only work if you have same number of directories to strip
echo "/gasg/string" |cut -d/ -f 3