简体   繁体   中英

Cat with heredoc does not work in zsh shell

When I try

cat > myfile << EOF
TEST TEXT
EOF

I just get an empty file. The same using echo command. What's going on? I can only think about something conflicting in the .zshenv profile file, but I have no idea about what it could be...

I am using zsh 4.3.6 (x86_64-suse-linux-gnu) .

This could happen if your /tmp (or wherever your $TMPDIR points) were read-only.

You should be able to discover what's wrong by attaching strace to the zsh you're running the above from, using eg strace -ff -s200 -o /tmp/zsh.log -p PID-goes-here from a different shell.

Here is another way to write it:

cat <<eos > filename
foo bar baz
eos

That works in zsh.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM