Version 2.3.2
See main post
Changelog
- Adjust gettext to work with updated MoManager (thanks to BarryK)
pProcess 2.3.2 - Process manager
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
I was playing around with awk to learn how to store associative arrays and ended up coming up with a way to replace ps that is almost as fast but with better configurability option ... so in case it is useful:
for gtkdialog you'd probably want to change the formatting fron printf "%-20s\t", field[argv[j]] to printf "%s|", field[argv[j]]
and replace the last printf "\n" with printf "<something useful>\n"
Code: Select all
#usage: my_ps [Options]
#Options
#Name:State:Tgid:Pid:PPid:TracerPid:Uid:Gid:FDSize:Groups:VmPeak:VmSize:VmLck:VmPin:VmHWM:VmRSS:VmData:VmStk:VmExe:VmLib:
#VmPTE:VmSwap:Threads:SigQ:SigPnd:ShdPnd:SigBlk:SigIgn:SigCgt:CapInh:CapPrm:CapEff:CapBnd:Seccomp:Cpus_allowed:
#Cpus_allowed_list:voluntary_ctxt_switches:nonvoluntary_ctxt_switches
my_ps(){
echo $@ | awk 'BEGIN{FN=0}
FNR==1{FN++}
FN==1{
argc=NF
for(j=0;j<NF;j++){
argv[j]=$(j+1)
field[FN][$(j+1)]=$(j+1)
}
}
FN>1{
title=substr($1,0,length($1)-1)
$1=""
field[FN][title]=$0
}
END{
for(i=1;i<FN;i++){
for(j=0;j<argc;j++){
printf "%-20s\t", field[i][argv[j]]
}
printf "\n"
}
}
' - /proc/*/status
}
and replace the last printf "\n" with printf "<something useful>\n"
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
Its not really faster per se, but its faster than using bash + all the extra utilities to get the same functionality as awk.zigbert wrote:Used in the right places, awk is like speed-of-light compared to bash.
btw if you decide you want to use it let me know and I can rework it to play well with busybox awk (switch from using 2d arrays)
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].