[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-bash] What is going on here? Line with multiple < redirects
From: |
Lane Schwartz |
Subject: |
[Help-bash] What is going on here? Line with multiple < redirects |
Date: |
Mon, 14 Dec 2015 10:26:53 -0600 |
I teach a class that includes intro to Bash. One of my students tried
something I'd never seen before, and I haven't been able to make sense of
how Bash is parsing this (admittedly bizarre) command.
$ ./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.
Any help figuring out what's going on would be appreciated. The complete
steps to reproduce follow:
$ seq 10 > sample.txt
part1.py:
#!/usr/bin/python3
>
>
> import sys
> import os
>
> os.mknod("part1_ran1.txt")
>
> for line in sys.stdin:
> print("PART1: {}".format(line.strip()))
part2.py:
#!/usr/bin/python3
>
>
> import sys
> import os
>
> os.mknod("part2_ran1.txt")
>
> for line in sys.stdin:
> print("PART2: {}".format(line.strip()))
part3.py:
#!/usr/bin/python3
>
>
> import sys
> import os
>
> os.mknod("part3_ran1.txt")
>
> for line in sys.stdin:
> print("PART3: {}".format(line.strip()))
$ ./part3.py < ./part2.py < ./part1.py < sample.txt
PART3: 1
> PART3: 2
> PART3: 3
> PART3: 4
> PART3: 5
> PART3: 6
> PART3: 7
> PART3: 8
> PART3: 9
> PART3: 10
$ ls
> part1.py part2.py part3.py part3_ran.txt sample.txt
- [Help-bash] What is going on here? Line with multiple < redirects,
Lane Schwartz <=