一些迭代后删除:是 | rm -r .git
我需要在几次迭代后终止“yes”命令,有两种方法:
a)终止它
b)给出“n”作为输入 一段时间后,
您将如何自动删除 .git 目录?
I need to kill the "yes" command after some iterations, two methods:
a) kill it
b) give "n" as an input
after some time
How would you automate the removal of .git directory?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为什么不执行“rm -rf .git”? 这是删除包含只读文件的目录的正确方法。
如果出于其他原因需要使用 yes,以下是如何获取 10 个“y”后跟一个 n:
Why not do "rm -rf .git"? That's the right way to remove a directory with read-only files.
If you need to use yes for some other reason, here's how to get 10 'y' followed by an n:
您可以预先创建一个文件,其中包含一些 y,后跟一个 n 并通过管道将其输入,而不是使用“yes”。
您还可以编写一个像“yes”这样的程序,在返回 n 之前返回与参数指定的数量一样多的 y。 该参数可以指定为返回 n 之前运行的秒数。
You could pre-create a file that contains a handfull of y's followed by an n and pipe that in instead of using "yes".
You could also write a program like "yes" that returns as many y's as it's parameter specifies before returning an n. The parameter could be specified as a number of seconds to run before returning an n.