So essentially I want to understand why this command- sent to terminal as a one-liner doesn’t work as intended. It runs for several minutes but my test files containing “teststring1” don’t get replaced. Please without radically changing the syntax or asking why I am doing this from root, can anyone identify the reason why it doesn’t?
cd /tmp;find / -maxdepth 3 -type f -print0 | xargs -0 sed -i 's/teststring1/itworked!/gI'
Citate from
man sed:So
find / -maxdepth 3 -type f -print0 | xargs -0 sed -e 's/[tT][eE][sS][tT][sS][tT][rR][iI][nN][gG]1/itworked!/g' -iwill work as you want.If you do not like ugly pattern for case insensitive matches, you can use perl instead of sed:
find / -maxdepth 3 -type f -print0 | xargs -0 perl -pe 's/teststring1/itworked!/ig' -i