Skip to main content
added 11 characters in body
Source Link
George Vasiliou
  • 8.1k
  • 3
  • 24
  • 43

Check also this awk simple solution. Will remove the string no matter where it is and should be portable:

$ echo "testa="test.xyz|test3.abc|test5232.lop|filename.test|file.text|qwerty.bat" $ |awkawk -F"test5232.lop." '{printf("%s%s\n",$1,$2)}' <<<"$a" 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:

awk -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 

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:

awk -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 

Check also this awk simple solution. Will remove the string no matter where it is and should be portable:

$ a="test.xyz|test3.abc|test5232.lop|filename.test|file.text|qwerty.bat" $ awk -F"test5232.lop." '{printf("%s%s\n",$1,$2)}' <<<"$a" 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:

awk -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 
deleted 1 character in body
Source Link
George Vasiliou
  • 8.1k
  • 3
  • 24
  • 43

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:

gawkawk -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 

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 

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:

awk -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 
added 843 characters in body
Source Link
George Vasiliou
  • 8.1k
  • 3
  • 24
  • 43

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 

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 

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 
Source Link
George Vasiliou
  • 8.1k
  • 3
  • 24
  • 43
Loading