[Gloucs] bash Q

Glyn Davies glynd at walmore.com
Sun May 13 16:06:35 BST 2007


One for Dr Bash et al.

I have some files in a directory. They have random names (usually based 
on date) but all end in .00n (where n is a number i.e. .001, .002, etc)

I have a script to rename the files based on their creation time. That 
bit works fine. However, I want to maintain the suffix of the original 
file. The problem is that some of the original files contain '.'s in the 
non suffix part.

So, for example:

03042006.001 will become 20060403.001

The suffix is easily found with echo 03042006.001 | awk -F. '{ print $2}'

04.05.2006.001 will  become 20060504.001

The awk line above returns 05 for this filename (as it should)

In short, how can you obtain the part of the filename after the last '.'?


-- 
Best Regards
Glyn Davies



More information about the gloucs mailing list