Reputation: 951
I'm using a df command to show disk space but want to grep each line separately:
Filesystem Size Used Avail Capacity Mounted on
/dev/disk2 59Gi 22Gi 37Gi 38% /
/dev/disk3s2 11Ti 5.2Ti 5.7Ti 48% /Volumes/UserStorage
/dev/disk4s2 11Ti 5.9Ti 5.0Ti 54% /Volumes/UserStorage-BACKUP
I need to extract the values from /Volumes/UserStorage separate from /Volumes/UserStorage-BACKUP
But the following still gives me both:
% df -Pklh | grep /Volumes/UserStorage
/dev/disk3s2 11Ti 5.2Ti 5.7Ti 48% /Volumes/UserStorage
/dev/disk4s2 11Ti 5.9Ti 5.0Ti 54% /Volumes/UserStorage-BACKUP
Ideas how to get each line separately, I.e.
/dev/disk3s2 11Ti 5.2Ti 5.7Ti 48% /Volumes/UserStorage
then
/dev/disk4s2 11Ti 5.9Ti 5.0Ti 54% /Volumes/UserStorage-BACKUP
??
Upvotes: 0
Views: 207
Reputation: 174696
You need to use end of the line anchor $
df -Pklh | grep '/Volumes/UserStorage$'
This would match the line which has exactly /Volumes/UserStorage
string present at the end.
Upvotes: 1