How to split string on forward slash in bash

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

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)