Site icon New Generation Enterprise Linux

Master `ps` Output with Custom `awk` Formatting

Quick Tip

Master `ps` Output with Custom `awk` Formatting

Challenge: The default output of the `ps` command can be overwhelming, making it difficult to quickly find specific process information like CPU usage, memory consumption, or the full command line for a process.

The Solution: You can leverage `awk` to parse and format the `ps` output for cleaner and more targeted information.

ps aux | awk '{print $1, $2, $3, $4, $11}'

Why it works: `awk` is a powerful text-processing utility that can select specific fields (columns) from its input. In this case, `ps aux` provides detailed process information, and `awk ‘{print $1, $2, $3, $4, $11}’` selects and prints the user, PID, CPU%, MEM%, and the command name, respectively.

Pro-Tip: To see the full command line, including arguments, you can use `ps aux | awk ‘{print $1, $2, $3, $4, substr($0, index($0,$11))}’` which captures everything from the 11th field onwards.

Linux Tips & Tricks | © ngelinux.com | 6/6/2026

0 0 votes
Article Rating
Exit mobile version