exampleecho "${FILE%.*}"# => example.tarecho "${FILE#*.}"#; 铁雪资源网更新日期:2024/12/26">
(编辑:jimmy 日期: 2024/12/26 浏览:2)
basename example.tar.gz .tar.gz # => example FILE="example.tar.gz" echo "${FILE%%.*}" # => example echo "${FILE%.*}" # => example.tar echo "${FILE#*.}" # => tar.gz echo "${FILE##*.}" # => gz # 在bash中可以这么写 filename=$(basename "$fullfile") extension="${filename##*.}" filename="${filename%.*}"