Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!


Forgot your password?
Check out the new SourceForge HTML5 internet speed test! No Flash necessary and runs on all devices. ×
User Journal

Journal Mmm coffee's Journal: A little bash help?

Learning bash scripting by writing a "dir" script that emulates the look and feel of Windows's dir command. I have a problem that I can't quite figure out. I want to make text (say in a variable $i) uppercase. So far I've made it work using a fuxx0red up sed command -

nameinupper=$(echo ${filename[$outputcount]} | sed -e 's/a/A/g' -e 's/b/B/g'\
      -e 's/c/C/g' -e 's/d/D/g' -e 's/e/E/g' -e 's/f/F/g' -e 's/g/G/g' -e 's/h/H/g'\
      -e 's/i/I/g' -e 's/j/J/g' -e 's/k/K/g' -e 's/l/L/g' -e 's/m/M/g' -e 's/n/N/g'\
      -e 's/o/O/g' -e 's/p/P/g' -e 's/q/Q/g' -e 's/r/R/g' -e 's/s/S/g' -e 's/t/T/g'\
      -e 's/u/U/g' -e 's/v/V/g' -e 's/w/W/g' -e 's/x/X/g' -e 's/y/Y/g' -e 's/z/Z/g');

I could care less that it's ugly. I do care that it really kills the speed of the script. Is there a better way to make text upper case in a bash script without having to write a C program that uses toupper()?

This discussion has been archived. No new comments can be posted.

A little bash help?

Comments Filter:

Happiness is a positive cash flow.