{"action":"created","issue":{"url":"https://api.github.com/repos/fish-shell/fish-shell/issues/2675","labels_url":"https://api.github.com/repos/fish-shell/fish-shell/issues/2675/labels{/name}","comments_url":"https://api.github.com/repos/fish-shell/fish-shell/issues/2675/comments","events_url":"https://api.github.com/repos/fish-shell/fish-shell/issues/2675/events","html_url":"https://github.com/fish-shell/fish-shell/issues/2675","id":126993390,"number":2675,"title":"Pipe Loop Output to File","user":{"login":"zQueal","id":239193,"avatar_url":"https://avatars.githubusercontent.com/u/239193?v=3","gravatar_id":"","url":"https://api.github.com/users/zQueal","html_url":"https://github.com/zQueal","followers_url":"https://api.github.com/users/zQueal/followers","following_url":"https://api.github.com/users/zQueal/following{/other_user}","gists_url":"https://api.github.com/users/zQueal/gists{/gist_id}","starred_url":"https://api.github.com/users/zQueal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zQueal/subscriptions","organizations_url":"https://api.github.com/users/zQueal/orgs","repos_url":"https://api.github.com/users/zQueal/repos","events_url":"https://api.github.com/users/zQueal/events{/privacy}","received_events_url":"https://api.github.com/users/zQueal/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-01-16T01:58:54Z","updated_at":"2016-01-16T02:35:41Z","closed_at":null,"body":"I'm trying to generate seed data. For which I'm using a bunch of commands to generate data. (doesn't have to be random)\r\n\r\n    while true\r\n        sleep 1\r\n        date +%s | sha256sum | base64 | head -c 32; echo\r\n    end\r\n\r\nI want to be able to let this file generate a string every 1 second, but to print to both stdout __and__ to a file on my HDD.\r\n\r\nAnyone have a solution here? I've been searching the documentation but have come up empty.\r\n\r\nI tried using standard operators to create and add a new file;\r\n\r\n    while true\r\n        sleep 1\r\n        date +%s | sha256sum | base64 | head -c 32 >> data.seed\r\n    end\r\n\r\nWhich _does_ work, however, there's no separation of newlines. All text is just in one large file with no spaces or new lines. I've also noticed that things like `echo \\n` work, but when I add it to the echo command, all data output is replaced with a new line, instead of the data _and_ a new line."},"comment":{"url":"https://api.github.com/repos/fish-shell/fish-shell/issues/comments/172148404","html_url":"https://github.com/fish-shell/fish-shell/issues/2675#issuecomment-172148404","issue_url":"https://api.github.com/repos/fish-shell/fish-shell/issues/2675","id":172148404,"user":{"login":"krader1961","id":7545917,"avatar_url":"https://avatars.githubusercontent.com/u/7545917?v=3","gravatar_id":"","url":"https://api.github.com/users/krader1961","html_url":"https://github.com/krader1961","followers_url":"https://api.github.com/users/krader1961/followers","following_url":"https://api.github.com/users/krader1961/following{/other_user}","gists_url":"https://api.github.com/users/krader1961/gists{/gist_id}","starred_url":"https://api.github.com/users/krader1961/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krader1961/subscriptions","organizations_url":"https://api.github.com/users/krader1961/orgs","repos_url":"https://api.github.com/users/krader1961/repos","events_url":"https://api.github.com/users/krader1961/events{/privacy}","received_events_url":"https://api.github.com/users/krader1961/received_events","type":"User","site_admin":false},"created_at":"2016-01-16T02:35:41Z","updated_at":"2016-01-16T02:35:41Z","body":"Put the __tee__ command outside the __while__ block should work. For example,\r\n\r\n```fish\r\nwhile true\r\n   whatever\r\nend | tee -a data.seed\r\n```\r\n\r\nHowever I just tested that and it doesn't work. I consider that a bug but given fish doesn't claim to be POSIX compliant it may not be. I'll defer to @ridiculousfish for whether or not that is a bug.\r\n\r\nRegardless, I'm pretty certain that even if that construct worked you would not find it satisfactory due to the buffering done by the stdio library when writing into a pipe. I'm willing to bet you want this formulation:\r\n\r\n```fish\r\nwhile true\r\n    sleep 1\r\n    set -l t (date +%s | sha256sum | base64 | head -c 32)\r\n    echo $t\r\n    echo $t > data.seed\r\nend\r\n```"}}