Linked Questions
14 questions linked to/from How portable are /dev/stdin, /dev/stdout and /dev/stderr?
20
votes
2
answers
4k
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 ...
155
votes
6
answers
363k
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 example ...
94
votes
4
answers
64k
views
How to pass a string to a command that expects a file?
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 ...
26
votes
2
answers
6k
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, ...
16
votes
3
answers
13k
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 see ...
7
votes
2
answers
19k
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 ...
7
votes
1
answer
1k
views
Why does MacOS always append to a redirected file descriptor even when told to overwrite? Ubuntu only appends when strictly told to append
Given the following code:
out="$(mktemp)"
rm -f "$out"
clear
printf '%s\n' 0 >"$out"
{
printf '%s\n' '1' >/dev/stdout
printf '%s\n' '2' >/dev/stdout
} &...
2
votes
3
answers
1k
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/...
5
votes
3
answers
764
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 ...
3
votes
2
answers
2k
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.
...
3
votes
2
answers
3k
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
2
answers
1k
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 ...
-2
votes
3
answers
2k
views
Creating a wordlist to speed up pdfcrack
I had shared about pdfcrack earlier here. Now it is boring and will take a long time for pdfcrack to crack the password.
But what if I could help it using a wordlist that might make the whole ...
1
vote
1
answer
2k
views
How can a subshell return data in a variable (not file) and output distinct logs at the same time?
Say I've got the following javascript:
const something = doSomething();
function doSomething() {
console.log("About to do something");
const a = ...