>>截取路徑/aaa/bbb/ccc/ddd 中/aaa/bbb/ccc

1.sed 's/\(.*\)\/.*/\1/'

2.awk -F\/ 'BEGIN{OFS="/"}{$NF="";print $0}'