Home | Mirror | Search

2. filename

$ basename /usr/bin/find
find
    	

2.1. 排除副檔名

file=test.txt
b=${file%.*}
echo $b
	    	
$ for file in *.JPG;do mv $file ${file%.*}.jpg;done 	
	    	

2.2. 取副檔名

file=test.txt
b=${file##*.}
echo $b	    	
	    	
comments powered by Disqus