Issue
I have 100 files with lines like the following:
ABC+123+74859308812345'XYZ
ABC+12+64859603759604'XYZ
ABC+41+73596027485910'XYZ
In all files, I want to replace the first 10 numbers after the second +
with NEWREF
like this:
ABC+123+NEWREF2345'XYZ
ABC+12+NEWREF9604'XYZ
ABC+41+NEWREF5910'XYZ
Solution
You can use to modify the content of the file.
sed -i 's/[0-9]\{10\}/NEWREF/g' <filename>
let's say if test is the file name then.
sed -i 's/[0-9]\{10\}/NEWREF/g' test
now you can use this command in a loop to iterate for 100 files or you can use ls with a pattern to pass the list of files in which replacement to be done.
sed -i 's/[0-9]\{10\}/NEWREF/g' `ls <filename pattern>`
Answered By - vikas singhal