Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does writing data to stdout in linux occupy disk space?

I want to know whether writing data to stdout on a terminal in linux occupies disk space. I tried to look up information about stdout and tty in the man page, but it seems no answer to the question.

Thanks for any tip.

I have a router on which I have installed openwrt, but the total space of the router is 2MB and now there is only 12KB left. And I want to run a bash script to print some information on the terminal in the openwrt system. So I want to know whether it could occupy disk space when printing data to stdout.

like image 395
flyer Avatar asked Sep 17 '25 04:09

flyer


2 Answers

stdout is not a specific file, or a location (disk, memory, etc.) - it is a concept. Usually, when talking about stdout in linux applications, we mean a file like object (ie. supporting (write, flush, etc.).

Output can be redirected to a real file on disk in which case, writing to stdout can and will use up disk space.

like image 145
wroniasty Avatar answered Sep 18 '25 17:09

wroniasty


Unless the output is being redirected (though pipes to e.g. tee, or to a file with the > shell redirection operator), then no, output will not go to a file system. Output to a console (or terminal emulator) is slow as it is, passing it through the file system would make it even slower, and may not allow the disks to spin down if there's a lot of output.

It may, however, end up in the swap space, if the OS thinks the process should be swapped out before the output is actually written.

like image 45
Some programmer dude Avatar answered Sep 18 '25 17:09

Some programmer dude