0 like 0 dislike
15 views
How to zip all files named with test in centos via PHP
asked Jul 27 in Education & Reference by Neha (690 points) | 15 views
    

1 Answer

0 like 0 dislike
echo $res = `find /var/www/html/Test -maxdepth 1 -name "test*"  -daystart -mtime 0 -ls`;

//0 means from today , so for example 1 means 1 day old

$main_array = (explode(PHP_EOL,$res));
//print_r($main_array);

$main_array = array_map(function($arr){ $a = explode("/", $arr, 2); return $a[1]; }, $main_array);
//print_r($main_array);
$main_array = array_map(function($arr){ $a = explode("/", $arr); $size = sizeof($a) - 1; return $a[$size]; }, $main_array);

$cmd = "tar -zcvf test-".date(Ymd).".tgz ";
$files = implode(" ", $main_array);

$rese = `$cmd.$files`;
//echo "==>".$cmd.$files;
answered Jul 27 by anonymous

Related questions

0 like 0 dislike
1 answer
1 like 0 dislike
1 answer
1 like 0 dislike
1 answer
0 like 0 dislike
1 answer
1 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
1 like 0 dislike
1 answer
asked Sep 7, 2017 in Education & Reference by Krish (890 points) | 19 views

Where your donation goes
Technology: We will utilize your donation for development, server maintenance and bandwidth management, etc for our site.

Employee and Projects: We have only 15 employees. They are involved in a wide sort of project works. Your valuable donation will definitely boost their work efficiency.

How can I earn points?
Awarded a Best Answer 10 points
Answer questions 10 points
Asking Question -20 points

Mathe Forum Schule und Studenten
1,164 questions
1,304 answers
275 comments
1,589 users