一些迭代后删除:是 | rm -r .git

发布于 2024-08-01 20:56:27 字数 104 浏览 5 评论 0原文

我需要在几次迭代后终止“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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

弃爱 2024-08-08 20:56:27

为什么不执行“rm -rf .git”? 这是删除包含只读文件的目录的正确方法。

如果出于其他原因需要使用 yes,以下是如何获取 10 个“y”后跟一个 n:

(yes | head -10; echo n) | rm -r .git

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:

(yes | head -10; echo n) | rm -r .git
傾旎 2024-08-08 20:56:27

您可以预先创建一个文件,其中包含一些 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文