Linked Questions
10 questions linked to/from What is an open file description?
37
votes
5
answers
38k
views
How can same fd in different processes point to the same file?
Say I have process 1 and process 2. Both have a file descriptor corresponding to the integer 4.
In each process however the file descriptor 4 points to a totally different file in the Open File Table ...
21
votes
2
answers
6k
views
Why is the behavior of `command 1>file.txt 2>file.txt` different from `command 1>file.txt 2>&1`?
When you want to redirect both stdout and stderr to the same file, you can do it by using command 1>file.txt 2>&1, orcommand &>file.txt.
But why is the behavior of command 1>file....
25
votes
3
answers
5k
views
How does this script ensure that only one instance of itself is running?
On 19 Aug 2013, Randal L. Schwartz posted this shell script, which was intended to ensure, on Linux, "that only one instance of [the] script is running, without race conditions or having to clean up ...
6
votes
4
answers
2k
views
In Linux, is there a system layer/script that handles the opening of files?
in Linux, is there a layer/script that handles program-requests to open files?
Like when you open a file-descriptor in bash: exec 3 <>/documents/foo.txtor your text-editor opens /documents/foo....
7
votes
2
answers
13k
views
What exactly is a file offset in lsof output?
I was using lsof to track down deleted files that were still taking up space and I realized that I wasn't quite sure what an offset is with respect to a file. lsof's man page was less than helpful in ...
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 ...
12
votes
3
answers
2k
views
What characterizes a file in Linux/Unix?
What characterizes a file in Linux/Unix?
A file can have many types: regular file, directory, symlink, device file, socket, pipe, fifo, and more that I miss. For example, a symlink:
$ sudo file /...
6
votes
1
answer
776
views
Application behaves weirdly with `>>`, replaces lines instead of appending
The application itself is not in question, I am just wondering how the Bash around is not behaving as I expected it to, like somehow whatever behaviour this application has, it is leaking out in a way ...
0
votes
2
answers
518
views
Redirecting stdout with > and stderr with >> to same file leaves out stderr
I'm redirecting stdout and stderr to the same file by using > and >> respectively:
rsync -a --exclude cache/ src_folder/ target_folder/ 1>out_err.log 2>>out_err.log
However the ...
0
votes
1
answer
115
views
Understanding bash ‘<’ and ‘>’ with parentheses
Let's say we have a folder with two files:
file_empty, containing nothing
file_in, containing just one line: "something"
See the output of the following examples:
(echo "test" &...