[英]How to write linux grep, sed, diff sentences in a php file or in a perl file
I want to compare 2 text files using Diff, grep, and sed.我想使用 Diff、grep 和 sed 比较 2 个文本文件。
First, How to write linux grep, sed, diff sentences in a php file or in a perl file?一、如何在php文件或perl文件中编写linux grep、sed、diff语句?
how to write this diff in php or perl:如何在 php 或 perl 中编写此差异:
$ diff C:/Users/User/Desktop/text1.txt C:/Users/User/Desktop/text2.txt > C:/Users/User/Desktop/text3.txt
how to write this sed in php or perl:如何在 php 或 perl 中编写此 sed:
$ sed -i -r 's/.{2}//' C:/Users/User/Desktop/text3.txt
Second, What is better?第二,什么更好? writing it in PHP file or Perl file?
写在 PHP 文件或 Perl 文件? I want to call this script from PHP file.
我想从 PHP 文件调用这个脚本。
Thank you.谢谢你。
Edit 1: I try this:编辑1:我试试这个:
$text_files_path = "C:/inetpub/wwwroot/dbs";
$command = ("diff $text_files_path/$OldDbFile $text_files_path/$NewDbFile > $text_files_path/diffFile.txt");
exec($command);
it generate the new file in the specified folder but, it is empty!它在指定的文件夹中生成新文件,但它是空的!
Try this :尝试这个 :
<?php
echo exec("sed -i -r 's/.{2}//' C:/Users/User/Desktop/text3.txt");
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.