Saving following script in a file:

cat <<EOF | wc -l

and executing it gives the following error:

$ ./a.sh 
./a.sh: line 1: cannot create temp file for here-document: No space left on device

My Debian thinks that there is no space left on the device (which is not true, but it's out of our context). However I have a plenty of RAM space. Since my tools (scripts) also refuse to work because of this error, I'm unable to resolve the actual "no space left" issue. What can I do to make my scripts use the RAM for the "heredoc" handling process in order to get them working at least, so that I can move forward to resolve the actual problem by using my tools?

2 Answers 2


Point the $TMPDIR variable to some directory that is on a RAM disk/tmpfs, since that's the variable that determines where the shell (at least bash) creates its temporary files.


Find a mount with the tmpfs filesystem

grep tmpfs /etc/mtab

in my case, one of the lines is

 tmpfs /run/user/1000 tmpfs rw,nosuid,nodev,relatime,size=808468k,nr_inodes=202117,mode=700,uid=1000,gid=1000 0 0

then as @telcoM mentions do

export TMPDIR=/run/user/1000

(or use that for a file, like wc -l $(hostname) >> /run/user/1000/myexample)

BTW, is that $(hostname) just an example or what do you expect from that?

  • $(hostname) was just an example, I didn't really care its output. BTW, I overcome the problem by deleting some files from /tmp, so I probably will apply your solution next time I encounter the problem (or simulate somehow). I think I'll come across with it again in the near future.
    – ceremcem
    Jun 20 at 7:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.