How do I retrieve only the needed line from terminal output?
This will output the 3rd line, regardless of content.
df -h | sed -n 3p
df command actually accepts an argument identifying the filesystem you want. So you could use, for example,
df /home or
If you intend to parse the output for a script, you'll want to use
df -P to guarantee it never wraps to multiple lines. So, for example, you could use
df -Ph /home | tail -n +2 (but if you're parsing output for a script, be aware of the possibility of filenames with spaces in them)
You can use a combination of
df -h | head -3 | tail -1
df -h | tail -n +3 | head -1
But note that,
df allows to filter the output from the options of
df itself, you should look at those first before using any external command.