bash 获取文件名

First, get file name without the path:

  • filename="\((basename "\)fullfile")"
  • extension="${filename##*.}"
  • filename="${filename%.*}"
  • Alternatively, you can focus on the last '/' of the path instead of the '.' which should work even if you have unpredictable file extensions:

filename="${fullfile##*/}"

posted @ 2021-08-24 15:20  千心  阅读(272)  评论(0编辑  收藏  举报