Issue
i have a file with below line
aadz(mdb awetyi),Lll,Dweuio: mdb 1:00.0 ARF = 0x000000006e1d9000
i want to locate ARF = 0x000000006e1d9000
and perform positional replacement of certain positions like 12,13,14 etc with x. the final result should look like
aadz(mdb awetyi),Lll,Dweuio: mdb 1:00.0 ARF = 0x000000006xxx000
i tried this command
sed -i -e 's/\(.\{12\}\)./\1x/' -e 's/\(.\{13\}\)./\1x/' -e 's/\(.\{74\}\)./\1x/' file
but it replaces the characters from start of the line containing the text which is not desired
I'm unable to locate only ARF = 0x000000006xxx000
Solution
You can do it with the following command
sed -E 's/(ARF = .{11}).{3}/\1xxx/g' file
It matches ARF =
, 11 following symbols and replaces following three symbols with xxx
Option -i
is not included in example: first test to see that replacement is happening like you want.
Answered By - markalex Answer Checked By - Katrina (WPSolving Volunteer)