2016-11-05 113 views
2

我使用差異和排序來找出2個文件之間的差異。從Linux提示符下面的工作完美:PHP exec/diff/No such file

diff <(sort /real/path/yesterday.txt) <(sort /real/path/today.txt) > diff-today.txt 

但我沒能得到同樣的命令,使用EXEC()從PHP運行:

exec("diff <\(sort /real/path/yesterday.txt\) <\(sort /real/path/today.txt\) > diff-today.txt"); 

我收到以下錯誤:

sh: (sort: No such file or directory 

有沒有想法?

回答

0

將大命令分解爲小命令。將文件逐個排序,然後執行差異。此代碼爲我工作。

echo exec('sort /real/path/yesterday.txt > /real/path/yesterday_sorted.txt ; sort /real/path/today.txt > /real/path/today_sorted.txt ; diff /real/path/yesterday_sorted.txt /real/path/today_sorted.txt > diff-today.txt'); 
+0

Thx。有時只是將它分開就更容易了:-) – clund

相關問題