3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $log = "(9143308-9144331):246221357-246222380, (IND):246222381, (9144332-9145355):246222382-246223405, (IND):246223406, (9145356-9146379):246223407-246224430, (IND):246224431, (9146380-9147403):246224432-246225455, (IND):246225456, (9147404-9148427):246225457-246226480, (IND):246226481, (9148428-9149451):246226482-246227505, (IND):246227506, (9149452-9150475):246227507-246228530, (IND):246228531, (9150476-9151499):246228532-246229555, (IND):246229556, (9151500-9152523):246229557-246230580, (IND):246230581, (9152524-9153547):246230582-246231605, (IND):246231606, (9153548-9154571):246231607-246232630, (IND):246232631, (9154572-9155027):246232632-246233087, (9155028-9155595):246233115-246233682, (IND):246233683, (9155596-9156619):246233684-246234707, (IND):246234708, (9156620-9157643):246234709-246235732, (IND):246235733, (9157644-9158667):246235734-246236757, (IND):246236758, (9158668-9159691):246236759-246237782, (IND):246237783, (9159692-9160715):246237784-246238807, (IND):246238808, (9160716-9161739):246238809-246239832, (IND):246239833, (9161740-9162763):246239834-246240857, (IND):246240858, (9162764-9163787):246240859-246241882, (IND):246241883, (9163788-9164811):246241884-246242907, (IND):246242908, (9164812-9165835):246242909-246243932, (IND):246243933, (9165836-9166859):246243934-246244957, (IND):246244958, (9166860-9167883):246244959-246245982, (IND):246245983, (9167884-9168907):246245984-246247007, (IND):246247008, (9168908-9169931):246247009-246248032, (IND):246248033, (9169932-9170955):246248034-246249057, (IND):246249058, (9170956-9171979):246249059-246250082, (IND):246250083, (9171980-9173003):246250084-246251107, (IND):246251108, (9173004-9173414):246251109-246251519, (9173415-9174027):246252034-246252646, (IND):246252647, (9174028-9175039):246252648-246253659 TOTAL: 9184010"; $out = '#!/bin/sh' . PHP_EOL; $matches = array(); if (preg_match_all('/((.*?)-(.*?)):(.*?)-(.*?),/m', $log, $matches)) { foreach ($matches as $match) { $blockSize = $match[1][1] - $match[1][0] + 1; $startingBlock = $match[1][3]; $out .= sprintf('fsgrab -c %s -s %s /dev/sdc2 >> "/media/root/TOSHIBA EXT/blabla"', $blockSize, $startingBlock) . PHP_EOL; } } echo $out;
based on pSS9V
Output for 7.1.0 - 7.2.0
Warning: A non-numeric value encountered in /in/Re24Q on line 11 Warning: A non-numeric value encountered in /in/Re24Q on line 11 Warning: A non-numeric value encountered in /in/Re24Q on line 11 Warning: A non-numeric value encountered in /in/Re24Q on line 11 Warning: A non-numeric value encountered in /in/Re24Q on line 11 Warning: A non-numeric value encountered in /in/Re24Q on line 11 #!/bin/sh fsgrab -c 1 -s N /dev/sdc2 >> "/media/root/TOSHIBA EXT/blabla" fsgrab -c 1 -s N /dev/sdc2 >> "/media/root/TOSHIBA EXT/blabla" fsgrab -c 1 -s N /dev/sdc2 >> "/media/root/TOSHIBA EXT/blabla" fsgrab -c -7 -s 5 /dev/sdc2 >> "/media/root/TOSHIBA EXT/blabla" fsgrab -c 3 -s 2 /dev/sdc2 >> "/media/root/TOSHIBA EXT/blabla" fsgrab -c 3 -s 2 /dev/sdc2 >> "/media/root/TOSHIBA EXT/blabla"
Output for 5.3.21 - 7.0.20
#!/bin/sh fsgrab -c 1 -s N /dev/sdc2 >> "/media/root/TOSHIBA EXT/blabla" fsgrab -c 1 -s N /dev/sdc2 >> "/media/root/TOSHIBA EXT/blabla" fsgrab -c 1 -s N /dev/sdc2 >> "/media/root/TOSHIBA EXT/blabla" fsgrab -c -7 -s 5 /dev/sdc2 >> "/media/root/TOSHIBA EXT/blabla" fsgrab -c 3 -s 2 /dev/sdc2 >> "/media/root/TOSHIBA EXT/blabla" fsgrab -c 3 -s 2 /dev/sdc2 >> "/media/root/TOSHIBA EXT/blabla"