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?
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?
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
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.