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.
给定的是字符串:dog apple orange banana
dog apple orange banana
我需要做到:monkey apple cow banana
monkey apple cow banana
那就是没有调用 sed 两次。
以下 sed 示例应该可以解决您的问题。sed 允许多个 -e 开关,这允许您一次替换多个东西。
sed -e 's/dog/monkey/g' -e 's/orange/cow/g'
用于;对命令进行排队:
;
sed -e 's/dog/monkey/g;s/orange/cow/g'