gpt4 book ai didi

php - 从 file1 file2 获取公共(public)数据的 comm 命令

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:07:24 26 4
gpt4 key购买 nike

我想获取 file1 和 file2 中的公共(public)数据。

<?php 
$cmd="comm -12 <(sort /Source/20-07-2015/file1 | uniq) <(sort /Source/20-07-2015/file2 | uniq) > /20-07-2015/commondata_20072015-248932-ac.csv";
$result =exec($cmd);
?>

但是上面的代码抛出了一个错误:

sh: -c: line 0: syntax error near unexpected token `('

最佳答案

PHP exec()使用 shsh不支持 <(...) .

最简单的修复(来自知道 sh/bash 但不知道 PHP 的人)是拥有 sh调用 bash运行你的命令:

$cmd="bash -c 'comm -12 <(sort /Source/20-07-2015/file1 | uniq) <(sort /Source/20-07-2015/file2 | uniq) > /20-07-2015/commondata_20072015-248932-ac.csv'";

关于php - 从 file1 file2 获取公共(public)数据的 comm 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31525013/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com