How do I write a bash script to replace words in files and then rename files?

Posted by Jason on Stack Overflow See other posts from Stack Overflow or by Jason
Published on 2011-01-13T23:59:00Z Indexed on 2011/01/14 0:53 UTC
Read the original article Hit count: 119

Hi All,

I have a folder structure, as shown below:

alt text

I need to create a bash script that does 4 things:

  1. It searches all the files in the generic directory and finds the string 'generic' and makes it into 'something'
  2. As above, but changes "GENERIC" to "SOMETHING"
  3. As above, but changes "Generic" to "Something"
  4. Renames any filename that has "generic" in it with "something"

Right now I am doing this process manually by using the search and replace in net beans. I dont know much about bash scripting, but i'm sure this can be done. I'm thinking of something that I would run and it would take "Something" as the input.

Where would I start? what functions should I use? overall guidance would be great. thanks.

I am using Ubuntu 10.5 desktop edition.

© Stack Overflow or respective owner

Related posts about linux

Related posts about bash