Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【每日一题】- 2020-10-09 - 以下 shell 的作用是什么? #151

Closed
azl397985856 opened this issue Oct 9, 2020 · 3 comments
Closed

Comments

@azl397985856
Copy link
Owner

mkfifo pipe1
mkfifo pipe2
echo -n run | cat - pipe1 > pipe2 &
cat <pipe2 > pipe1
@suukii
Copy link

suukii commented Oct 9, 2020

mkfifo pipe1
  • 创建了一个 FIFO(named pipe) pipe1(可以把它看成一个文件)
mkfifo pipe2
  • 创建了一个 FIFO(named pipe) pipe2
echo -n run | cat - pipe1 > pipe2 &
  • echo run 输入字符串 run-n 参数去除 trailing line
  • | pipe to
  • cat - pipe1 > pipe2 将输入(run) 和 pipe1(暂时没有内容) 的内容输入到 pipe2
  • & run in background
cat < pipe2 > pipe1
  • 将 pipe2 的内容作为 cat 命令的输入,然后再输出到 pipe1 中。

一顿操作之后,pipe1 和 pipe2 中的内容都是 run

通过 google 之后猜的 ╮(╯▽╰)╭

@feikerwu
Copy link
Contributor

feikerwu commented Oct 9, 2020

新建两个命名管道pipe1, pipe2, 将两个管道两端接合,形成一个环,字符串在两个管道间不断拷贝。整挺好,就是死循环废机器。

@stale
Copy link

stale bot commented Dec 8, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Dec 8, 2020
@stale stale bot closed this as completed Dec 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants