Zsh管道输出到命令

时间:2015-07-29 15:46:06

标签: bash shell zsh file-descriptor

在Zsh中,我知道你可以command &> file.txt所有文件描述符传递给file.txt(而不是像command 2>&1 3>&1 > file.txt那样单独执行每个文件描述符有三个文件描述符)。有没有办法将所有文件描述符传递给另一个命令?例如command <mystery operator> cat

编辑:我错了,正如Chepner和Etan指出的那样; &>仅重定向fd的1和2.谢谢!

1 个答案:

答案 0 :(得分:7)

command仅重定向标准输出和标准错误,而不是command |& grep # Equivalent to command 2>&1 | grep 可能写入的所有文件描述符。但是,等效管道是

Projects.insert({
    source: "https://upload.wikimedia.org/wikipedia/commons/7/7f/Pug_portrait.jpg",
    title: "Pug",
    artist: "pug",
    description: "This piece shows the duality of pug",
    price: "$50"
});

Projects.insert({
    source: "http://c.fastcompany.net/multisite_files/fastcompany/poster/2014/01/3025003-poster-p-dog-2.jpg",
    title: "Dog",
    artist: "dog",
    description: "much doge, many deal with it, wow",
    price: "$50"
})

Projects.insert({
    source: "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ea/Van_Gogh_-_Starry_Night_-_Google_Art_Project.jpg/1280px-Van_Gogh_-_Starry_Night_-_Google_Art_Project.jpg",
    title: "Starry Night",
    artist: "van gogh",
    description: "night sky with stars",
    price: "$75"
})

Projects.insert({
    source: "http://totallyhistory.com/wp-content/uploads/2012/03/The_Scream.jpg",
    title: "Scream",
    artist: "edvard",
    description: "scream",
    price: "$50"
})

Projects.insert({
    source: "https://www.petfinder.com/wp-content/uploads/2012/11/dog-how-to-select-your-new-best-friend-thinkstock99062463.jpg",
    title: "Dog 2",
    artist: "Bittu",
    description: "This is a test to see how an actual thing would work",
    price: "$50"
})