intdup2(intoldfd,intnewfd);
dup2()createacopyofthefiledescriptoroldfd.Afterasuccessfulreturnfromdup()ordup2(),theoldandnewfiledescriptorsmaybeusedinterchangeably.Theyrefertothesameopenfiledescription(seeopen(2))andthussharefileoffsetandfilestatusflags;forexample,ifthefileoffsetismodifiedbyusinglseek(2)ononeofthedescriptors,theoffsetisalsochangedfortheother.
编写一个C程序,经由过程挪用sort这个Shell命令举行排序,请求把in.txt和out.txt分离重定向到sort的STDIN,STDOUT。
欢迎光临 仓酷云 (http://ckuyun.com/) | Powered by Discuz! X3.2 |