Need help regarding df command and spaces
Hey Guys..
Just to clarify.. I am running the command on a Mac .. but due to it being a generic unix command and a command line query.. I thought I can write on this forum.. I am running the command Code:
df -h | grep '/dev/' Code:
/dev/disk0s2 389Gi 62Gi 327Gi 16% / This is because currently I have some NAS drives mounted.. which are not showing due to grep.. when they are not mounted.. the output is fine.. with equal spaces between each column (like between col 2 and 3.. or 3 and 4) I want to do a (dare I say) sed or awk or something to reduce the space between 1st and 2nd col. so that it has space like between col 3 and 4.. or 2 and 3.. This is because I am showing this output somewhere and because of the space its not showing up correctly.. Also I hope the command will still work when the NAS drives (afp) are not mounted.. basically consistency.. Hope i explained myself properly.. any help is great :D EDIT: Damn.. after posting realized.. the spaces are not showing properly in the quote tag.. changed it to CODE tag |
Something like this?
Code:
echo "/dev/disk3s2 500Gi 47Gi 453Gi 10% /Volumes/Misc" | sed -r 's/ {20}//g' Beware that using this approach can result in funky results if the figures for the sizes vary widely. Cheers, Tink |
Quote:
Well, another approach How about we restrict the 1st column to say 12 characters?? can we do that.. so no matter whatevr is the name of 1st column... it will cut itself and present neatly.. I am not concerned with the full name to appear in first column... |
If your sed is antique you can just use
Code:
s/ //g Code:
s/ {20}//g |
How about:
Code:
df -h | awk '$1=$1' |
Quote:
1) Either restrict the 1st column output to 12 char (don't think that might work) OR 2) if I do Code:
df -lh Code:
Filesystem Size Used Avail Capacity Mounted on Code:
Filesystem Size Used Avail Capacity Mounted on |
Quote:
Code:
$ df -lh | grep -v '^F.\+' |
Thanks that worked.. just wondering if I mount external disks will df -lh show up..
anyways.. time will tell :D |
Quote:
|
Try this one ;}
Reasonably flexible, tested on slackware64 13.1 Code:
script, save as whatever Code:
df -lh | awk -f whatever Cheers, Tink |
Not sure what is on MAC, but if you have column:
Code:
df -h | awk 'NR > 1 && $1 = $1' | column -t |
Mungs the alignment.
+1 for Tink |
Looked fine on my screen :)
|
All times are GMT -5. The time now is 10:37 PM. |