Quick Tip
Taming `ps` Output with Custom `awk` Formatting
Challenge: The default output of the ps command can be verbose and difficult to parse for specific process information. Extracting just the process ID (PID) and the command name for all running processes can be tedious with manual parsing.
The Solution: Utilize awk to format the output of ps aux, showing only the PID and the command.
ps aux | awk '{print $2, $11}'
Why it works: awk is a powerful text-processing tool that can select specific columns from its input. In this case, `$2` refers to the second column (PID) and `$11` refers to the eleventh column (the command name) in the `ps aux` output.
Pro-Tip: You can easily modify the column numbers to extract other fields, such as the user ($1) or CPU usage ($3).
Linux Tips & Tricks | © ngelinux.com | 5/5/2026
