I have 2 mount points:
- /Volumes/Media
- /Volumes/Media Backup 1
When I execute df | grep -e /Volumes/Media
, both mount points are returned. I would like to be able to exclude /Volumes/Media Backup 1
from the results.
CodePudding user response:
Converting my comment to answer so that solution is easy to find for future visitors.
You may use any of these solutions:
# grep with end anchor and whitespace matching at start
df | grep -E '[[:blank:]]/Volumes/Media$'
# awk with non-regex approach that matches last field
df | awk '$NF == "/Volumes/Media"'
# sed that uses similar regex as grep
df | sed -n '\~[[:blank:]]/Volumes/Media$~p'