0

I'm trying to find a command or to create a script on linux allowing to switch a specific expression to lower-case in many files in subdirectories.

I need this to change the case in all the includes statements in a C++ project (Porting Visual studio project to linux)

So in many files I have

#include <Path1/pAth2/naMeofTheHeader.h>

and i would like to change it to

#include <Path1/pAth2/nameoftheheader.h>

(Of course I don't want the path to be moved in lower case)

Does anyone have an idea to perform this? I tried somme sed command (with \L) but anything have worked.

Thanks

johan
  • 45
  • 1
  • 7
  • Refer [http://stackoverflow.com/questions/2264428/converting-string-to-lower-case-in-bash-shell-scripting][1] [1]: http://stackoverflow.com/questions/2264428/converting-string-to-lower-case-in-bash-shell-scripting – Fazlin Sep 30 '14 at 14:10
  • You should always show what you've tried. – glenn jackman Sep 30 '14 at 15:24

1 Answers1

3

You could try the below sed command,

sed 's~\(#include .*\/\)\([^\/.]*\)~\1\L\2~g' file

Example:

$ echo '#include <Path1/pAth2/naMeofTheHeader.h>' | sed 's~\(#include .*\/\)\([^\/.]*\)~\1\L\2~g'
#include <Path1/pAth2/nameoftheheader.h>
Avinash Raj
  • 172,303
  • 28
  • 230
  • 274