how to delete the nth occurrence of a character in a string bash shell -


i have string this: str="test,test,test,test,test,test". how can delete nth comma (,) in string str, n between 1 , 5? can give suggestion? thank you.

$ echo "$str" test,test,test,test,test,test $ sed 's/,//5' <<<"$str" #or echo "$str" |sed 's/,//5' test,test,test,test,testtest 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -