取目录 echo "/etc/fstab" |sed -r 's#(^/.*/)([^/]+/?)#1#' 取基名 echo "/etc/fstab" |sed -r 's#(^/.*/)([^/]+/?)#2#'