I would suggest something like this:
for i in *-doc-*.txt; do mv "$i" "${i/*-doc-/doc-}"; done
${i/*-doc-/doc-}
replaces the first occurrence of *-doc-
with doc-
.
If you need to do more than one replacement (see comment number 1), you need to use the ${var//Pattern/Replacement}
variant. If you need to replace the beginning of the name you need to use ${var/#Pattern/Replacement}
, if you need to replace the end (ie: the extension) you need to use the ${var/%Pattern/Replacement}
form.
See Shell Parameter Expansion for more details. This expansion is bash specific.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…