BASH rename .log to .LOG

I am having a hard time understanding this. I have researched brace expansion and the mv command but for some reason it still isn't making sense to me. I am reading Unix and Linux system administration handbook and they use this as an example, but I'm not understanding the line:

mv $fname ${fname/.log/.LOG};

I realize it is moving the current $fname variable which is anything with .log but the ${fname/.log/.LOG}; is confusing me. I thought it was basically mv source destination... So why are there 2 /'s? If someone could explain this to me in plain english I would be most appreciative!


find . -type f -name '*.log' | grep -v .do-not-touch | while read fname;
mv $fname ${fname/.log/.LOG/};


The mv line should be interpreted as "Move $fname to ${fname/.log/.LOG}". The ${var/pattern/string} construct is one form of the Parameter Expansion called Pattern Substitution. It returns the variable's value with the first occurrence of the pattern replaced by the string. In other words, it replaces .log with .LOG in this case. Therefore, for each file, the line is something like

mv file.log file.LOG

Need Your Help

THREE JS 3ds Max Gradients not applied

webgl three.js 3dsmax

I exported my 3d model from 3ds Max as json using threejsexporter ( and as .obj (which I then converted to json us...

read cdata from a rss feed

php xml cdata

I'm reading a rss feed using simple code:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.