views:

119

answers:

2

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?

+3  A: 

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
Nelson
He wants it to stop after a while apparently.
Bill K
Ohh, that's good :)
Bill K
+1 very nice indeed :)
Masi
A: 

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.

Bill K