-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathpsa
More file actions
executable file
·34 lines (29 loc) · 799 Bytes
/
psa
File metadata and controls
executable file
·34 lines (29 loc) · 799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
help() {
echo 'usage: psa [-w] [pattern]'
echo
echo ' Show all processes in full detail (ps faux) excluding kernel'
echo ' processes. If a pattern is given, then the process list is'
echo " grep'ed with that pattern."
echo
echo ' psa will by default chop off long lines.'
echo
echo ' -w wrap lines instead of chopping them off'
echo
echo ' psa depends on the 'linechop' tool.'
exit 1
}
[ "$1" == "--help" ] && help
if [ "$1" == "-w" ]; then
shift
chopper="cat"
else
chopper="linechop"
fi
if [ -z "$1" ]; then
# Pattern of kernel process in `ps auxw` :
# ... 0:00 [kthreadd]
ps faux | grep -v -P '\d:\d\d \\_ \[.*\]$' | $chopper
else
ps faux | grep -v -P '\d:\d\d \\_ \[.*\]$' | grep "$1" | $chopper
fi