linux - Find X occurence of string in file and replace to static string -


i need again. need find 3 , 4 occurrence of comma (accross line) , replace specific string, let's assume:

"text","text2","text3","text4","text5" "text6","text7","text8","text9","text10" 

now, replace text4,text9,text5,text10 eg. "static"

 "text","text2","text3","static","static"  "text6","text7","text8","static","static" 

which function should use? know 'sed' proper that, how count commas?

edit: (simpler version 3 occurence of comma)

i need find 3 occurrence of comma (accross line) , replace specific string, let's assume:

"text","text2","text3","text4","text5" "text6","text7","text8","text9","text10" 

now, replace text4,text9 eg. "static"

 "text","text2","text3","static","text5"  "text6","text7","text8","static","text5" 

this awk one-liner works given example. changes text in 4th , 5th columns/fields:

awk -f, -v ofs="," '{i=4;while(i<6)gsub(/\w+/,"static",$(i++))}7' file 

Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -