shell - sed positional replacement with regular expression -
shell - sed positional replacement with regular expression -
i have string
select dateadd(dd,-90, max(col_name)) table_123_name
and want output
select max(col_name) -90 table_123_name
i have tried
cat test.txt|sed "s/dateadd(dd,//i g"|sed 's/\(\[select\]\)\([ \s\t]*\)\([0-9-]*\)\(\[,\]\)\([ \s\t]*\)\([a-za-z0-9(_]*[)]*\)/select \6)\3/i g'
but regular look replace not working
you this,
$ echo 'select dateadd(dd,-90, max(col_name)) table_123_name' | sed 's/dateadd(dd,\([^,]*\), *\([^) ]*)\)) *\(.*\)/\2 \1 \l\3/gi' select max(col_name) -90 table_123_name
i
modifier @ lastly helps case-insensitive match , \l\3
turns chars nowadays within 3rd capturing grouping lowercase.
shell sed
Comments
Post a Comment