<? Php
Error_reporting (0 );
Echo "\ n". "Enter the file to be sorted:". "\ n ";
$ Dic = trim (fgets (STDIN ));
$ File = file ($ dic );
$ Array = preg_replace ('/($ \ s * $) | (^ \ s * ^)/m', '', $ file); // clear empty rows
$ New_array = array_values (array_unique ($ array); // eliminate duplicate rows
$ New_filename = "new _". basename ($ dic); www.2cto.com
If (file_put_contents ("$ new_filename", join ("\ r \ n", $ new_array ))){
Echo "----------------------------------------". "\ r \ n ";
Echo "\ n". "repeated removal is completed! "." \ R \ n ";
Echo "the file after deduplication is:". "\ r \ n ";
Echo dirname (_ FILE _). DIRECTORY_SEPARATOR. "$ new_filename". "\ r \ n ";
Echo "----------------------------------------". "\ r \ n ";
}
Else {
Echo "----------------------------------------". "\ r \ n ";
Echo "error! "." \ R \ n ";
Echo "file not found! Check whether the input path exists! "." \ R \ n ";
Echo "----------------------------------------". "\ r \ n ";
Exit ();
}
?>
From http://hi.baidu.com/nginxshel