Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试用相同的字符替换某些字符,但\n在它前面。
\n
所以我想做,像,replace (a|b|c|d) with \n + (same character as before)。
replace (a|b|c|d) with \n + (same character as before)
有谁知道解决这个问题的好方法?
尝试:
data_producing_command | sed 's/[abcd]/\n&/g'
例如
cat myFile.txt | sed 's/[abcd]/\n&/g'
您可以使用sed. 只需通过以下方式捕获有问题的\1角色\(...\):
sed
\1
\(...\)
sed 's/\([abcd]\)/\n\1/g'