Reputation: 2082
Assume the following output:
➜ ~ df -kl
Filesystem 1024-blocks Used Available Capacity iused ifree %iused Mounted on
/dev/disk1 487401624 207950512 279195112 43% 52051626 69798778 43% /
/dev/disk2s2 732238672 242656088 489582584 34% 60664020 122395646 33% /Volumes/Backup Drive
I would like to extract '43%' (column %iused) from the output above. What would I do to match '/'? I get the feeling I need to escape it. In the past I matched a specific string (i.e. CPU usage) without any issue. I would use something like:
top -l 1 | awk '/CPU usage:/ {print $3}'
But the '/' is giving me trouble. Any ideas?
Upvotes: 0
Views: 31
Reputation: 203684
From your comments it sounds like this might be what you want:
df -kl | awk '$NF=="/"{ print $8 }'
If not, do edit your question to clarify.
Upvotes: 2
Reputation: 16351
Should be simple! Try this:
df -kl | awk '/^\// { print $5 }'
We tell it to find lines where the line starts with a slash. We specify the slash by escaping it.
Upvotes: 2