How can I write a sed expression, which looks through a line to match
Id int
and change to
Id string
this will be the only content in that line (nothing other than, Id int) and should not alter other lines.
I tried with something along the lines
find . -type f -print0 | xargs -0 sed -i '' 's~^\([[:space:]]*\)"Id"[[:space:]]*"int"[:space:]]*$~\1"Id string"~g'
But the reg exp is wrong.
Thanks.
Edit:
To clarify further:
There are spaces (inconsistent) before Id
, between Id
and int
. So, needs to match [[:space:]]* , instead of tab or expressions like s/^Id int$
so the lines to match can be
Id int
Id int
Id int
It can be replaced with
Id string
Id string
Id string
means, no need to preserve the number of spaces