I’m trying to write a shell script which recursively goes through a directory, then in each file converts all Uppercase letters to lowercase ones. To be clear, I’m not trying to change the file names but the text in the files.
Considerations:
- This is an old Fortran project which I am trying to make more accessible
- I do not want to create a new file but rather write over the old one with the changes
- There are several different file extensions in this directory, including .par .f .txt and others
What would be the best way to go about this?
To convert a file from lower case to upper case you can use
ex(a good friend ofed, the standard editor):or, if you like stuff on one line:
Combining with
find, you can then do:This method is 100% safe regarding spaces and funny symbols in the file names. No auxiliary files are created, copied or moved; files are only edited.
Edit.
Using glenn jackmann‘s suggestion, you can also write:
(the pro is that it avoids awkward escapes; the con is that it’s longer).