I want to replace part of filename with specified character.
For example:
$ ls
SubNetwork=RNCRAM955E,MeContext=RNCRAM955E_statsfile.xml
I want to replace RNCRAM955E
with RNCMST954E
Here comes my expected output.
$ ls
SubNetwork=RNCMST954E,MeContext=RNCMST954E_statsfile.xml
and below is my code:
$ find ./ -name '*.xml' | xargs -i echo mv {} {} | sed 's/RNCRAM955E/RNCMST954E/3g' | sh
mv ./SubNetwork=RNCRAM955E,MeContext=RNCRAM955E_statsfile.xml ./SubNetwork=RNCMST954E,MeContext=RNCMST954E_statsfile.xml
mv ./SubNetwork=RNCRAM955E,MeContext=RNCRAM955E_statsfile.xml ./SubNetwork=RNCMST954E,MeContext=RNCMST954E_statsfile.xml
mv ./SubNetwork=RNCRAM955E,MeContext=RNCRAM955E_statsfile.xml ./SubNetwork=RNCMST954E,MeContext=RNCMST954E_statsfile.xml
mv ./SubNetwork=RNCRAM955E,MeContext=RNCRAM955E_statsfile.xml ./SubNetwork=RNCMST954E,MeContext=RNCMST954E_statsfile.xml
I can't understand what's the code of 3g
exactly mean.
In my opinion:
Does the sed s/xx/xx/3g
means replace match pattern from the 3rd one to the end ,and the sed s/xx/xx/3
means only replace the 3rd match pattern?
BTW, what's the exactly mean of |sh
, I think it makes the command after echo
as a shell executing, right ?