What does the left angle bracket after a while loop mean in bash?

后端 未结 2 390
粉色の甜心
粉色の甜心 2021-01-19 00:48

The following is from /etc/init.d/functions on RHEL. I\'m trying to figure out what the __pids_var_run() function does when I came across this while loop.

相关标签:
2条回答
  • 2021-01-19 01:22

    It means that any command in the loop that reads something from stdin will read from the given file (instead of the keyboard, for example).

    In this case in particular, the loop uses read line to read a single line from stdin, so when you redirect from $pidfile it effectively reads the file line by line.

    To further read about redirections, here's an Illustrated redirection tutorial which is recommended by this Bash Guide by Lhunath and GreyCat.

    0 讨论(0)
  • 2021-01-19 01:34

    I see that this quesiton is already answered (I cannot comment because I did a bounty), but I think you should check out this site when you get a chance:

    http://mywiki.wooledge.org/BashFAQ/001

    This guy (or gal) really dives in to proper and improper syntax with examples.

    0 讨论(0)
提交回复
热议问题