How can I use less with the following requirements?
1. I want to use less and scroll up and down with the arrow keys.
2. If the entire output fits on the screen, less should automatically exit.
3. When I type something and press Enter, less should exit, and the input should be passed to read or to a variable, so I can process it.
4. I don't want to use
:q
, Ctrl-C, or similar commands to exit.
Example,I run lsblk | less
and want to enter a device name like sdx, which should be passed to a variable for further processing. Is this possible? I would appreciate a solution.
Asked by MotorCheck
(185 rep)
Mar 25, 2025, 07:56 PM
Last activity: Mar 26, 2025, 05:51 AM
Last activity: Mar 26, 2025, 05:51 AM