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.
我有一个文件,我想搜索具有特定世界的行并在其末尾附加一个句子我该怎么做?
cat test.txt |sed 's/searchString/&addedString/' > new.txt
“&”指的是匹配的字符串。这是真实的例子
qifei@qifei] cat test.txt ~ aaaa bbbb cccc aaaa qifei@qifei] cat test.txt |sed 's/aaaa/&bbbb/' > new.txt ~ qifei@qifei] cat new.txt ~ aaaabbbb bbbb cccc aaaabbbb