将文本附加到以字符串开头的所有文件
如何将字符串附加到目录中以特定字符串开头的所有文件?
我尝试过,
cat mysig >> F*
但它没有将 mysig 的内容附加到以 F 开头的所有文件,而是创建了一个名为“F*”的文件。显然通配符似乎不起作用。 还有其他选择吗? 提前致谢。
编辑: 另外,如何安全地删除这个新创建的文件“F*”?使用
rm F*
会删除所有我不想要的以 F 开头的文件。
How do I append a string to all the files in a directory that starts with a particular string?
I tried,
cat mysig >> F*
But instead of appending contents of mysig to all files starting with F, it creates a file named "F*". Obviously wildcard doesn't seem to work.
Any alternatives?
Thanks in advance.
Edit:
Also how do I delete this newly created file "F*" safely?. Using
rm F*
would delete all the files starting with F which I wouldn't want.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
shell 无法直接执行此操作,因为只有一个来自源程序(在本例中为猫)的流。
您需要一个帮助程序,例如 tee。试试这个:
The shell can't do that directly, since there will only be a single stream coming from the source program (the cat, in this case).
You need a helper program, such as tee. Try this:
*
是一个特殊字符 - 您需要引用它*
is a special character - you need to quote it