You are writing a Bash automation script that must read block-device information with simple shell tools. The script expects each field to be delivered as key="value" pairs (for example, NAME="sda" UUID="1234-ABCD") so it can be parsed safely regardless of column spacing. Which single option supplied to lsblk will generate its output in this parsable key-value format?
The lsblk option that produces key="value" pairs is -P (or its long form, --pairs). When this flag is used, lsblk prints every selected column as KEY="value", making the output easy to consume with read or while loops in shell scripts.
-J (--json) switches lsblk to JSON output, which is suitable for tools that understand JSON but does not use key="value" pairs per line.
-l (--list) removes the tree view and prints a simple list, but it still relies on fixed columns instead of key=value formatting.
-p (--paths) shows full device paths such as /dev/sda, yet the output remains in the default columnar layout. Therefore, only the -P / --pairs option meets the requirement.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is the purpose of the -P option in lsblk?
Open an interactive chat with Bash
How does the -P option differ from the -J option in lsblk?
Open an interactive chat with Bash
Why might a script require key="value" pairs instead of columnar output?
Open an interactive chat with Bash
CompTIA Linux+ XK0-006 (V8)
System Management
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
IT & Cybersecurity Package Join Premium for Full Access