grepping last word of output
Hi all,
I am trying to write a script in perl. It executes df -h and reads the input : /dev/sda7 688M 45M 608M 7% /scratch /dev/sda3 981M 17M 915M 2% /tmp /dev/sda8 494M 282M 187M 61% /usr/vice/cache /dev/sda5 981M 69M 862M 8% /var I want to get input in an array , where it contains only last field namely -> /scratch, /tmp, /usr/vice/cache, /var @arr = <xyz>; takes the whole line as input and I can parse it. But when partition names vary from machines to machines, that ofcourse is not a good idea. Kindly suggest what to do ??? Regards, Rajat Garg SU |
I beleive this should work for what you want:
Code:
#!/usr/bin/perl |
you can start with
df | cut -c57- |
df -h | awk '{ print $NF }'
|
All times are GMT -5. The time now is 06:56 AM. |