Tag Info

New answers tagged


It should be enough to just grep for digits followed by one or more rs: lsof | grep -P '\b\d+r+\b' Or, if you don't have GNU grep: lsof | grep -E '\b[0-9]+r+\b' The \bs mark word boundaries and ensure that only entire fields are matched. Alternatively, if your grep supports it, you can use the -w flag: lsof | grep -wE '[0-9]+r+' So, using that, ...


Answering your question literally, here's one way to list the last PID displayed by lsof: lsof … | awk 'END {print $2}' Awk is a text processing language which reads input and processes it line by line. In the code, END {…} executes the code in the braces after the whole input is processed, and effectively operates on the last line. $2 is the second ...

Top 50 recent answers are included