Skip to content

Instantly share code, notes, and snippets.

@Commifreak
Created June 11, 2021 06:14
Show Gist options
  • Save Commifreak/62826b1515900575fc3f9e641d3c8f58 to your computer and use it in GitHub Desktop.
Save Commifreak/62826b1515900575fc3f9e641d3c8f58 to your computer and use it in GitHub Desktop.
R - Show commonly used packages of users
<?php
$pkgs = [];
$libs = 'R/x86_64-pc-linux-gnu-library';
chdir('/home');
$users = glob('*.*');
foreach($users as $user) {
chdir('/home');
echo $user.PHP_EOL;
if(is_dir($user)) {
chdir($user);
} else {
continue;
}
if(is_dir($libs)) {
chdir($libs);
$rvers = glob('*');
foreach($rvers as $rver) {
echo '.....'.$rver.PHP_EOL;
if(!chdir('/home/'.$user.'/'.$libs.'/'.$rver)) {
echo "Skipping...".PHP_EOL;
continue;
}
$ulibs = glob('*');
foreach($ulibs as $lib) {
echo '...............'.$lib.PHP_EOL;
if(array_key_exists($lib, $pkgs)) { $pkgs[$lib]++; } else { $pkgs[$lib] = 1; }
}
}
}
}
asort($pkgs);
echo PHP_EOL.PHP_EOL;
foreach($pkgs as $pkg => $cnt) {
if($cnt > 1) {
echo str_pad($pkg, 20).': '.$cnt.' User'.PHP_EOL;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment