FAQ
Login
GNU social JPは日本のGNU socialサーバーです。
Usage
/
ToS
/
admin
/
test
/
Pleroma FE
Public
Public
Network
Groups
Featured
Popular
People
Embed Notice
HTML Code
<blockquote style="position: relative; padding-left: 55px;"><section><a href="https://social.jvns.ca/users/b0rk/statuses/113408479591556325">Julia Evans (b0rk@social.jvns.ca)'s status on Saturday, 02-Nov-2024 02:41:18 JST</a><a href="https://social.jvns.ca/@b0rk" title="b0rk@social.jvns.ca"><img src="https://gnusocial.jp/avatar/88850-48-20230116234922.webp" width="48" height="48" alt="Julia Evans" style="position: absolute; left: 0; top: 0;">Julia Evans</a></section><article><p>pipes & redirects cheat sheet</p></article><footer><a rel="bookmark" href="https://gnusocial.jp/conversation/3919183#notice-7657458">In conversation</a><time datetime="2024-11-02T02:41:18+09:00" title="Saturday, 02-Nov-2024 02:41:18 JST">about 20 days ago</time> <span>from <span><a href="https://social.jvns.ca/@b0rk/113408479591556325" rel="external" title="Sent from social.jvns.ca via ActivityPub">social.jvns.ca</a></span></span><a href="https://social.jvns.ca/@b0rk/113408479591556325">permalink</a><h4>Attachments</h4><ol><li><label><a rel="external" href="https://gnusocial.jp/attachment/3388484">panel 1: the magic of pipes is that you can use any program with any other programANYTHING that outputs text => ANYTHING that takes text inputpanel 2: pipe some outputenv | grep MAILpanel 3: redirect stdout to a filepbpaste > ~/bin/git-veepanel 4: ignore error outputfind . 2>/dev/nullpanel 5: pipe both stderr and stdout to a programcmd 2>&1 | lesspanel 6: redirect both stderr and stdout to the same filecmd &> file.txtcmd > file.txt 2>&1panel 7: gotcha: sudo echo blah > file.txt doesn't workif `file.txt` is owned by root, you have to doecho blah | sudo tee file.txtpanel 8: gotcha: grep blah file.txt > file.txt will make file.txt emptyyou can use sponge but I always just make sure to write to a different filepanel 9: gotcha: ./some_program | grep blah often gets bufferedthis is because libc buffers writes to files and pipesworkaround: unbuffer some_program | grep blah(unbuffer is part of expect)</a></label><br><a href="https://cdn.masto.host/socialjvnsca/media_attachments/files/113/408/478/607/373/110/original/1206e8debbaa33c8.png" rel="external">https://cdn.masto.host/socialjvnsca/media_attachments/files/113/408/478/607/373/110/original/1206e8debbaa33c8.png</a></li></ol></footer></blockquote>
Corresponding Notice
Embed this notice
Julia Evans (b0rk@social.jvns.ca)'s status on Saturday, 02-Nov-2024 02:41:18 JST
Julia Evans
pipes & redirects cheat sheet