0

Extract filename from path with bash

Posted by admin on Nov 18, 2009 in Allgemein

x=/etc/postfix/master.cf
echo ${x##*/} # = master.cf
echo ${x#*.} # = cf
echo ${x%.*} # = /etc/postfix/master
echo ${x%/*} # = /etc/postfix

echo ${x/.*}|awk -F/ '{print $NF}' # = master

Schlagwörter: ,

Copyright © 2017 Stempell All rights reserved. Theme by Laptop Geek.