0

I tried doing this:

yes > yes.txt

Afterwards, yes.txt is created but is completely empty.

11
  • 1
    Cannot reproduce on OS X (BSD). Can you yes | cat -v > yes.txt, maybe your yes implementation yes somehow prevents writing into a file?
    – Daniel Beck
    Dec 4, 2011 at 8:58
  • Also, you want to ask this on StackOverflow, I think.
    – tekknolagi
    Dec 4, 2011 at 9:00
  • 1
    @tekknolagi They'll just close it as off-topic. It's perfectly acceptable here.
    – Daniel Beck
    Dec 4, 2011 at 9:01
  • @DanielBeck okey doke
    – tekknolagi
    Dec 4, 2011 at 9:02
  • 2
    The source code to GNU yes does not indicate special handling of output to files. Are you sure that e.g. your disk isn't already full? Have you canceled the command, so e.g. buffering of writes to disk is no longer an issue?
    – Daniel Beck
    Dec 4, 2011 at 10:49

3 Answers 3

1

you want to do

`yes` > yes.txt

Which will execute yes and write the output to yes.txt


Note: yes command outputs a line, 'y' by default, endlessly - the abovementioned process will consume memory, cpu, and disk space until there is no free memory, after which it gets terminated. You may have to terminate it manually.

12
  • 2
    Have you actually tried this? ` yes ` will never finish, it'll just consume lots of memory!
    – Daniel Beck
    Dec 4, 2011 at 9:01
  • 1
    @DanielBeck that's what he wants... I did try it, in fact. He never asked if it was advisable :P
    – tekknolagi
    Dec 4, 2011 at 9:02
  • @DanielBeck see @ ChrisNava's answer, and @ RazorStorm's reply
    – tekknolagi
    Dec 4, 2011 at 9:03
  • 3
    please make sure you know what `` or $() does before using that. @Daniel is right that only thing it does is a big memory consumption and termination after there is no free memory any more.
    – Cougar
    Dec 4, 2011 at 10:02
  • 1
    I agree with tekknolagi. If the OP wants to jump off a cliff, let it be.
    – surfasb
    Dec 4, 2011 at 15:32
1

your original solution yes > yes.txt should work ... although you could work around it like this

while true; do echo yes; done >> yes.txt
0

I found the solution; my harddrive was full >.<

2
  • 1
    If this was true, you should have received a No space left on device error.
    – bwDraco
    Dec 4, 2011 at 21:55
  • @Gryllida, remove some files and try again. at first I got a diskquota exceeded error while doing something else. I thought deleting the file would help, but the file didnt actually get deleted. Dec 5, 2011 at 6:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .