GNU social JP
  • FAQ
  • Login
GNU social JPは日本のGNU socialサーバーです。
Usage/ToS/admin/test/Pleroma FE
  • Public

    • Public
    • Network
    • Groups
    • Featured
    • Popular
    • People

cmd > file.txt cmd >> file.txt cmd < file.txt cmd 2> file.txt cmd > file.txt 2>&1 cmd1 | cmd2 cmd1 2>&1 | cmd2 three gotchas: 1. cmd file.txt > file.txt will delete the contents of file.txt some people use set -o noclobber (in bash/zsh) to avoid this But I just have "never read from and redirect to the same file" seared into my memory. 2. sudo echo blah > /root/file.txt doesn't write to /root/file.txt as root. Instead, do: echo blah | sudo tee /root/file.txt or sudo sh -c 'echo blah > /root/file.txt' 3. cmd 2>&1 > file.txt doesn't write both stdout and stderr to file.txt. Instead, do: cmd > file.txt 2>&1 panel 3: cat vs < I almost always prefer to do: cat file.txt | cmd instead of cmd < file.txt it usually works fine & it feels better to me using cat can be slower if it's a GIANT file though panel 4: &> and &| some shells support &> and &| to redirect/pipe both stdout and stderr (also some shells use |& instead of &|)

Download link

https://cdn.masto.host/socialjvnsca/media_attachments/files/114/717/426/615/255/898/original/6eb25d19670f06b2.png

Notices where this attachment appears

  1. Embed this notice
    Julia Evans (b0rk@social.jvns.ca)'s status on Saturday, 21-Jun-2025 04:52:29 JST Julia Evans Julia Evans

    here's the final version of the "redirects cheat sheet" draft I posted a while back!

    ("The Secret Rules of the Terminal is finished! 95 beta readers have read it! the copy editor is done! technical review is done! the illustrator has made the cover! It's going to be out on *****Tuesday June 24*****")

    In conversation about 14 days ago from social.jvns.ca permalink
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.