5 let PATH = stdenv.lib.concatStringsSep ":" [ "${coreutils}/bin" ];
 
   7 writeShellScriptBin "swaplist" ''
 
   9   # DESCRIPTION: print sorted swap usage of processes using it
 
  13   sudo grep -H '^Swap:' /proc/*/smaps 2>/dev/null |
 
  14   while IFS=: read -r file x size x
 
  20           if test "$pid" = "$lastpid"
 
  21            then swap=$(( swap + size ))
 
  24                    then printf "%u pid=%u cmd=%s\n" "$swap" "$lastpid" "$(tr '\000' ' ' </proc/"$lastpid"/cmdline)"