Reputation: 45
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
Upvotes: 0
Views: 59
Reputation: 174854
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>
Upvotes: 3