Print one column, then select rows before printing it
Print one column, then select rows before printing it
Answer
ps -ef | awk '{print $2}' ps -ef | awk '/sleep/ {print $2}' ps -ef | awk '/sleep/ {print 1, 2}'
Line 1 has an action and no pattern, so it runs on every record. Lines 2 and 3 add a regular-expression pattern matched against the whole record. The comma between two field references inserts a space; drop it and the values are concatenated.
POSIX.1-2024 (IEEE Std 1003.1-2024) Shell and Utilities: awk. The textbook names awk as a regex tool and never teaches it.