Check also this awk simple solution. Will remove the string no matter where it is and should be portable:
$ echo "test.xyz|test3.abc|test5232.lop|filename.test|file.text|qwerty.bat" |awk -F"test5232.lop." '{printf("%s%s\n",$1,$2)}' test.xyz|test3.abc|filename.test|file.text|qwerty.bat About your request for in-place editing , GNU AWK version > 4.1 also can make inplace edits according to gawk manual:
gawk -i inplace -v INPLACE_SUFFIX=.bak '{...}' But in any case, neither awk nor sed nor perl can achieve a real inplace editing. GNU sed Info Pages clarify this issue for us:
'-i[SUFFIX]' '--in-place[=SUFFIX]' This option specifies that files are to be edited in-place. GNU 'sed' does this by creating a temporary file and sending output to this file rather than to the standard output.(1). Meaning that you can use any solution in-here by appending at the end something like this:
awk/sed/perl/whatever oldfile >tmpfile && mvtmpfile oldfile && rm -f tmpfile