[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] What is going on here? Line with multiple < redirects
From: |
Greg Wooledge |
Subject: |
Re: [Help-bash] What is going on here? Line with multiple < redirects |
Date: |
Mon, 14 Dec 2015 12:23:25 -0500 |
User-agent: |
Mutt/1.4.2.3i |
On Mon, Dec 14, 2015 at 10:26:53AM -0600, Lane Schwartz wrote:
> $ ./part3.py < ./part2.py < ./part1.py < sample.txt
>
> In this example, part3.py appears to directly take sample.txt as input, and
> part2.py and part1.py appear to not execute.
Redirections are processed from left to right. Bash opens ./part2.py
for reading, then moves to the next. Bash opens ./part1.py for reading
(and closes the previously opened file), then moves to the next. Bash
opens sample.txt for reading (and closes the previously opened file).
The end result is that 3 files have been opened, but 2 of them were
closed. The final file remains open as standard input for ./part3.py.