protected function buildContentFiltering(Command $command, array $contains, $not = false) { foreach ($contains as $contain) { $expr = Expression::create($contain); $command->add('| xargs -I{} -r grep -I')->add($expr->isCaseSensitive() ? null : '-i')->add($not ? '-L' : '-l')->add('-Ee')->arg($expr->renderPattern())->add('{}'); } }
/** * {@inheritdoc} */ protected function buildContentFiltering(Command $command, array $contains, $not = false) { foreach ($contains as $contain) { $expr = Expression::create($contain); // todo: avoid forking process for each $pattern by using multiple -e options $command->add('| grep -v \'^$\'')->add('| xargs -I{} grep -I')->add($expr->isCaseSensitive() ? null : '-i')->add($not ? '-L' : '-l')->add('-Ee')->arg($expr->renderPattern())->add('{}'); } }
private function buildDatesFiltering(Command $command, array $dates) { foreach ($dates as $i => $date) { $command->add($i > 0 ? '-and' : null); $mins = (int) round((time() - $date->getTarget()) / 60); if (0 > $mins) { $command->add(' -mmin -0'); return; } switch ($date->getOperator()) { case '<=': $command->add('-mmin +' . ($mins - 1)); break; case '>=': $command->add('-mmin -' . ($mins + 1)); break; case '>': $command->add('-mmin -' . $mins); break; case '!=': $command->add('-mmin +' . $mins . ' -or -mmin -' . $mins); break; case '<': default: $command->add('-mmin +' . $mins); } } }