Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to convert a variable to lower case and strip a suffix at the same time. The variable contains a file name and I am stripping the extension:

for f in *.shp; do echo ${f%.*};done

To convert a variable to lowercase I know the command is,


But how do I convert ${f%.*} to lower case within the loop?

share|improve this question
This is not related to Ubuntu. suits this better – Rinzwind Nov 25 '12 at 18:18
Can it be migrated? – Sam007 Nov 25 '12 at 18:38
Probably not (have not seen it happen unless to meta). – Rinzwind Nov 25 '12 at 18:41
@Rinzwind This is definitely off-topic on Programmers. It would be on-topic on Stack Overflow and on Unix & Linux. I'm surprised that you consider it off-topic here. – Gilles Nov 25 '12 at 19:07
up vote 2 down vote accepted

This worked for me.

for f in *.shp; do a=${f,,}; echo ${a%.*}; done

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.