Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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,

${f,,}

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

share|improve this question
    
This is not related to Ubuntu. programmers.stackexchange.com 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
add comment

1 Answer

up vote 2 down vote accepted

This worked for me.

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

share|improve this answer
add comment

Your Answer

 
discard

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.