Es scheint, als gäbe es kein geeignetes Flag ps, daher müssen Sie entweder ein anderes Tool verwenden (ich persönlich bevorzuge htop) oder psein wenig mit der Ausgabe herumspielen. Ich denke du willst dabei bleiben ps. Hier ist ein schmutziges kleines Skript, das ich als Beispiel erstellt habe:
# get terminal width
WIDTH=`tput cols`
# pipe stdin to awk
cat | \
awk '\
BEGIN {
# set output format
CONVFMT="%.2f"
}
NR==1 {
# search first line for columns that need to be converted from K to M
for (i=1;i<=NF;i++)
# add condition for new columns if you want
if ($i=="VSZ" || $i=="RSS") {
# column numbers are stored in an array
arr[i]=i;
$i = $i "(MB)"
}
}
NR > 1 {
# edit appropriate columns
for (i in arr)
$i=$i/1024;
}
{
# print every line
print $0
}' | \
# format the output into columns and trim it to terminal width
column -t | cut -c 1-$WIDTH
Speichern Sie es in einer Datei prettyps.sh, machen Sie es beispielsweise ausführbar:
chmod + x prettyps.sh
und wie folgt verwenden:
ps ux | /path/to/prettyps.sh
Die Verwendung dieses Skripts hat den Nachteil, dass der ps-Ausgabe zusätzliche Prozesse hinzugefügt werden, aber es funktioniert trotzdem:
$ ps ux | ./prettyps.sh
USER PID% CPU% MEM VSZ (MB) RSS (MB) TTY STAT STARTZEITBEFEHL
pono 2658 0,0 0,0 358,88 4,29? Sl 02:33 0:00 / usr / bin / gnome-keyring
... Ausgabe abgeschnitten ...
pono 4507 0.0 0.0 19.14 1.81 pts / 1 S + 03:29 0:00 man
pono 4518 0.0 0.0 10.55 0.96 pts / 1 S + 03:29 0:00 pager
pono 4727 0,7 0,9 1143,59 53,08? SSL 04:10 0:24 / opt / sublime_text / subl
pono 4742 0,1 0,4 339,05 25,80? Sl 04:10 0:03 / opt / sublime_text / plug
pono 5177 0.0 0.0 19.23 1.32 pts / 0 R + 05:05 0:00 ps
pono 5178 0,0 0,0 4,34 0,61 pts / 0 S + 05:05 0:00 / bin / sh
Ich hoffe, dies hilft, einen Weg zu finden, der zu Ihnen passt.