$ printf 'a[]b[c]d[ef][g[h]i\n' | sed 's/\[[^][]*]/-/g' a-b-d-[g-i $ ed a a[]b[c]d[ef][g[h]i . s/\[[^][]*]/-/g p a-b-d-[g-i q ? q $