Linked Questions

14
votes
2answers
2k views

Unix systems without /dev/stdin, /dev/stdout, and /dev/stderr? [duplicate]

An answer I gave to a question, and the comments to it, had me read the POSIX Conformance section of the Base Definitions to figure out whether /dev/stdin, /dev/stdout and /dev/stderr were actually ...
132
votes
6answers
302k views

Usage of dash (-) in place of a filename

For a command, if using - as an argument in place of a file name will mean STDIN or STDOUT. But in this example, it creates a file with the name -: echo hello > - How can I make - in this ...
39
votes
4answers
11k views

How to pass a string to a command that expects a file? [duplicate]

Suppose a program cook takes one argument: the pathname of a text file containing the recipe of the food to cook. Suppose I wish to call this program from within a bash script, also suppose I already ...
22
votes
2answers
4k views

Portability of file descriptor links

I've always wondered this but never took the time to find out, so I'll do so now - how portable is the usage shown here of either /proc/$$/fd/$N or /dev/fd/$N? I understand POSIX guarantees /dev/null, ...
11
votes
3answers
7k views

sending output to /dev/stderr vs. >&2

In scripts, errors are usually sent to file descriptor 2 with &2, ie: echo "error" >&2 Sometimes /dev/stderr is used instead: echo "error" > /dev/stderr Looking at /dev/stderr, I ...
6
votes
2answers
8k views

What's the difference between “>&1” and “>/proc/self/fd/1” redirection?

I'm working on some script that being run by rc.local at startup, and I noticed that output redirection works quite strange. If I write something like echo "foo" >&1, it ends up in syslog, and ...
3
votes
3answers
559 views

Why can't `paste` print stdin next to stderr?

Usually paste prints two named (or equivalent) files in adjacent columns like this: paste <(printf '%s\n' a b) <(seq 2) Output: a 1 b 2 But when the two files are /dev/stdin and /dev/...
1
vote
2answers
417 views

Redirect output to either stdout or a file (not both)

I want to create a script that, when called interactively, writes to stdout, but if called from another script and variable EVENT_LOGGER is defined by the calling script, writes to file EVENT_LOGGER. ...
1
vote
1answer
1k views

Is it safe to use /dev/stdin if the program doesn't read from standard input but only from files?

I want to pipe the output of a program A in a program B. The program B doesn't support reading from stdin, only from files. Can I simply do A | B /dev/stdin ? In fact it seems it works, but I want ...
3
votes
2answers
562 views

stdout, stdin and stderr representation on AIX 7.1

I've been porting a bunch of scripts on AIX 7.1. I got no prior experience with this Unix system. The scripts were ran under /bin/sh and relied on /dev/stdout, /dev/stdin and /dev/stderr. These files ...
4
votes
3answers
213 views

Can you clean up temporary files before they are used in shell?

I want to avoid having temporary files laying around if my program crashes. UNIX is wonderful in that you can keep a file open - even after you delete it. So if you open the file, immediately ...