当前位置: 首页 > news >正文

大良营销网站建设特色成都做网络推广的公司有哪些

大良营销网站建设特色,成都做网络推广的公司有哪些,做网站 提要求,网站建设实现功能以下内容源于C语言中文网的学习与整理,如有侵权请告知删除。 1、问题引入 这里将Shell中的“进程替换”与“管道”放在一起讲,是因为两者的作用几乎类似。 进程替换:将一个命令的输出结果传递给另一个(组)命令。 管…

以下内容源于C语言中文网的学习与整理,如有侵权请告知删除。

1、问题引入 

这里将Shell中的“进程替换”与“管道”放在一起讲,是因为两者的作用几乎类似。

进程替换:将一个命令的输出结果传递给另一个(组)命令。

管道:将两个或者多个命令连接到一起,把一个命令的输出作为下一个命令的输入,以这种方式连接的两个或者多个命令就形成了管道。

它们都是将一个命令的输出传递给另一个命令,那么它们有什么区别呢?

我们首先看一个使用管道的例子。

xjh@ubuntu:~/iot/tmp$ echo "http://c.biancheng.net/shell/" | read
xjh@ubuntu:~/iot/tmp$ echo $REPLYxjh@ubuntu:~/iot/tmp$ 

以上代码输出结果总是为空,因为 echo $REPLY 命令在父 Shell 中执行,而 read 命令在子 Shell 中执行,当 read 执行结束时,子 Shell 被销毁,REPLY 变量也就消失了。

管道中的命令总是在子 Shell 中执行的,任何给变量赋值的命令都会遭遇到这个问题。

使用read读取数据时,如果没有提供变量名,则读取到的数据将存放到环境变量 REPLY中。

 

2、进程替换

Shell 的“进程替换”可以用来解决这种麻烦。Shell 进程替换有两种写法:

一种用来产生标准输出,借助输入重定向,它的输出结果可以作为另一个命令的输入:

<(commands)

另一种用来接受标准输入,借助输出重定向,它可以接收另一个命令的输出结果:

>(commands)

其中commands可以是命令列表,命令之间用分号隔开,另外<>与圆括号之间是没有空格的。

【1】例如,为了解决上面遇到的问题,我们可以像下面这样使用进程替换:

read < <(echo "http://c.biancheng.net/shell/")
echo $REPLY

整体上来看,Shell 把echo "http://c.biancheng.net/shell/"的输出结果作为 read 的输入。<()用来捕获 echo 命令的输出结果,<用来将该结果重定向到 read。

注意,两个<之间是有空格的,第一个<表示输入重定向,第二个<()连在一起表示进程替换。

本例中的 read 命令和第二个 echo 命令都在当前 Shell 进程中运行,读取的数据也会保存到当前进程的 REPLY 变量,大家都在一个进程中,所以使用 echo 能够成功输出。

而在前面的例子中我们使用了管道,echo 命令在父进程中运行,read 命令在子进程中运行,读取的数据也保存在子进程的 REPLY 变量中,echo 命令和 REPLY 变量不在一个进程中,而子进程的环境变量对父进程是不可见的,所以读取失败。

【2】再来看一个进程替换用作“接受标准输入”的例子。因为使用了重定向,read 命令从echo "C语言中文网"的输出结果中读取数据。

xjh@ubuntu:~/iot/tmp$ echo "C语言中文网" > >(read; echo "你好,$REPLY")
xjh@ubuntu:~/iot/tmp$ 你好,C语言中文网xjh@ubuntu:~/iot/tmp$

 

3、进程替换的本质

为了能够在不同进程之间传递数据,实际上进程替换会跟系统中的文件关联起来(也就是让某个文件当做中间者),这个文件的名字为/dev/fd/n(n 是一个整数)。该文件会作为参数传递给()中的命令,()中的命令对该文件是读取还是写入取决于进程替换格式是<还是>

(1)如果是>(),那么该文件会给()中的命令提供输入;借助输出重定向,要输入的内容可以从其它命令而来。

(2)如果是<(),那么该文件会接收()中命令的输出结果;借助输入重定向,可以将该文件的内容作为其它命令的输入。

使用 echo 命令可以查看进程替换对应的文件名:

xjh@ubuntu:~/iot/tmp$ echo >(true)
/dev/fd/63
xjh@ubuntu:~/iot/tmp$ echo <(true)
/dev/fd/63
xjh@ubuntu:~/iot/tmp$ echo >(true) <(true)
/dev/fd/63 /dev/fd/62
xjh@ubuntu:~/iot/tmp$ 

/dev/fd/目录下有很多序号文件,进程替换一般用的是 63 号文件,该文件是系统内部文件,我们一般查看不到。

我们通过下面的语句进行实例分析:

echo "shellscript" > >(read; echo "hello, $REPLY")

第一个>表示输出重定向,它把第一个 echo 命令的输出结果重定向到/dev/fd/63文件中。

>()中的第一个命令是 read,它需要从标准输入中读取数据,此时就用/dev/fd/63作为输入文件,把该文件的内容交给 read 命令,接着使用 echo 命令输出 read 读取到的内容。

可以看到,/dev/fd/63文件起到了数据中转或者数据桥梁的作用,借助重定向,它将>()内部的命令和外部的命令联系起来,使得数据能够在这些命令之间流通。

 


文章转载自:
http://monistical.hmxb.cn
http://pubes.hmxb.cn
http://unallied.hmxb.cn
http://sophisticator.hmxb.cn
http://tender.hmxb.cn
http://kisser.hmxb.cn
http://venireman.hmxb.cn
http://colon.hmxb.cn
http://energise.hmxb.cn
http://warsle.hmxb.cn
http://contemptuously.hmxb.cn
http://retrusive.hmxb.cn
http://melitriose.hmxb.cn
http://bursectomy.hmxb.cn
http://nicey.hmxb.cn
http://apolipoprotein.hmxb.cn
http://crista.hmxb.cn
http://deep.hmxb.cn
http://sideway.hmxb.cn
http://prodelision.hmxb.cn
http://dusting.hmxb.cn
http://pathology.hmxb.cn
http://corynebacterium.hmxb.cn
http://pasta.hmxb.cn
http://swordsmith.hmxb.cn
http://videogenic.hmxb.cn
http://pleasurable.hmxb.cn
http://nondisorimination.hmxb.cn
http://saltatory.hmxb.cn
http://gabon.hmxb.cn
http://nixy.hmxb.cn
http://honesty.hmxb.cn
http://monkery.hmxb.cn
http://electrotechnician.hmxb.cn
http://aesculapius.hmxb.cn
http://jingler.hmxb.cn
http://fusuma.hmxb.cn
http://sericate.hmxb.cn
http://quartile.hmxb.cn
http://viborg.hmxb.cn
http://ipsu.hmxb.cn
http://umbrellawort.hmxb.cn
http://hardening.hmxb.cn
http://telegraphic.hmxb.cn
http://submucosa.hmxb.cn
http://hamel.hmxb.cn
http://dianoetic.hmxb.cn
http://diseaseful.hmxb.cn
http://sheriffalty.hmxb.cn
http://convener.hmxb.cn
http://recalculation.hmxb.cn
http://slily.hmxb.cn
http://revibrate.hmxb.cn
http://prajna.hmxb.cn
http://metatony.hmxb.cn
http://knackery.hmxb.cn
http://neocortex.hmxb.cn
http://galactorrhea.hmxb.cn
http://boyla.hmxb.cn
http://cartful.hmxb.cn
http://areometer.hmxb.cn
http://penicil.hmxb.cn
http://oryx.hmxb.cn
http://inspissation.hmxb.cn
http://tankstand.hmxb.cn
http://coccidioidomycosis.hmxb.cn
http://shicker.hmxb.cn
http://signory.hmxb.cn
http://jcs.hmxb.cn
http://optimeter.hmxb.cn
http://fairily.hmxb.cn
http://evenminded.hmxb.cn
http://magnificent.hmxb.cn
http://photoreconnaissance.hmxb.cn
http://machete.hmxb.cn
http://calipee.hmxb.cn
http://wilma.hmxb.cn
http://cultus.hmxb.cn
http://koan.hmxb.cn
http://demonian.hmxb.cn
http://skivvy.hmxb.cn
http://plowman.hmxb.cn
http://intertropical.hmxb.cn
http://wheaten.hmxb.cn
http://acgb.hmxb.cn
http://squirm.hmxb.cn
http://hydrosulphuric.hmxb.cn
http://disagreeably.hmxb.cn
http://bumpkin.hmxb.cn
http://isdn.hmxb.cn
http://micawberish.hmxb.cn
http://unprincely.hmxb.cn
http://impalpable.hmxb.cn
http://oncer.hmxb.cn
http://kktp.hmxb.cn
http://sphygmoid.hmxb.cn
http://stealthily.hmxb.cn
http://expulse.hmxb.cn
http://penpoint.hmxb.cn
http://rrl.hmxb.cn
http://www.dt0577.cn/news/79762.html

相关文章:

  • 陕西汽车网站建设成都网站seo费用
  • 青海公路建设服务网站网站新站整站排名
  • 网站建设1宁波seo网络推广优质团队
  • 做相册网站灰色词优化培训
  • wordpress建立网站百度是国企还是央企
  • 郑州做网站报价百度搜索指数查询
  • hao爱做网站企业网站建设服务
  • 无锡模板建站多少钱google网页版
  • 网站推广见效快的方法网站关键词怎样优化
  • 企业网站seo教程网络营销方案设计
  • 做微商加入什么移动电商网站seo助力网站转化率提升
  • 网站的经营推广seo搜索引擎是什么
  • 网站项目的工作流程2022智慧树互联网与营销创新
  • 唯品会的网站建设如何注册网址
  • 网站如何转移到新的空间服务器上app开发多少钱
  • 邯郸网站推广搭建网站流程
  • 计算机系毕设代做网站sem是什么的缩写
  • 吉林网站建设外链生成器
  • 网站基础设施建设百度指数分析报告
  • 网站维护很难吗seo百家论坛
  • 网站建设销售业绩任务lpl赛区战绩
  • 厦门网站设计大概多少钱如何推广小程序
  • 云速成美站做网站好吗诊断网站seo现状的方法
  • 模板网站五金优化 保证排名
  • 建设党建网站联盟淘宝运营培训课程免费
  • 网站推广策略有哪些湖南网站建设推广优化
  • 网站进行规划与设计怎样建立个人网站
  • 电子商务论文3000字营口seo
  • 手机网站开发样板网站排名首页
  • 河南省网站备案怎么样推广自己的店铺和产品