Printf df to reformat into a "table"
Greetings.
I am currently rather stuck with my objective here, I am attempting to place the information within the df command into a printf command with only a single example from a book that I find rather confusing. Code:
divider============================== I attempted to do something here, not sure if this is any help or not. Code:
IFS=`df -h` |
There is a syntax error in your code, in that you are missing a semicolon in your while;do .. done construction.
One approach is to pipe the output of df -h into the loop Code:
df -h | while read Mounted Avail Used Size; Code:
while read Mounted Avail Used Size x y; |
@allend - the semi-colon is not required if the 'do' is no the next line :)
@OP - I would probably use awk as the df data is column oriented, but the while loop option shown by allend should also work just fine. You just need to tweak it to your requirements. Also, here is another alternative construct: Code:
while read ... |
Thanks for the suggestions, they worked excellently.
I decided to go and change it a bit so I got this Code:
while read File Size Used Avail Use Mounted x y Code:
Mount Avail Used Size ./Cha92.sh: line 5: n: command not found |
Hah well figured it out! Thanks for the help you guys.
|
Note that an old GNU df needs -P option
Code:
df -hP ... |
All times are GMT -5. The time now is 12:17 AM. |