pattern matching in Bash

Posted by Tim on Stack Overflow See other posts from Stack Overflow or by Tim
Published on 2010-03-21T18:27:23Z Indexed on 2010/03/21 18:31 UTC
Read the original article Hit count: 746

Filed under:
|

Hi,

Here is an example to get different parts of a filename

bash-3.2$ pathandfile=/tmp/ff.txt  
bash-3.2$ filename=$(basename $pathandfile)  
bash-3.2$ echo $filename    
ff.txt    
bash-3.2$ echo ${filename##*.}     
txt    
bash-3.2$ echo ${filename%.*}    
ff    

I was wondering what does ## and % mean in the patterns. How is the patten matching working?

Thanks and regards!

© Stack Overflow or respective owner

Related posts about bash

Related posts about pattern-matching