What are some common methods for parsing and extracting data from shell-executed commands in PHP?

When executing shell commands in PHP, it is common to need to parse and extract data from the output of those commands. One common method for achieving this is to use functions like `exec()`, `shell_exec()`, or `proc_open()` to run the command and capture its output. Once the output is captured, you can then use string manipulation functions like `explode()`, `preg_match()`, or `substr()` to extract the specific data you need.

// Example code to parse and extract data from a shell-executed command
$command = 'ls -l';
$output = shell_exec($command);

// Extracting file names from the ls command output
$lines = explode("\n", $output);
foreach($lines as $line) {
    $parts = preg_split('/\s+/', $line);
    if(count($parts) >= 8) {
        $filename = end($parts);
        echo $filename . "\n";
    }
}