Sunday, May 5, 2024
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 2799  / 1 Year ago, mon, december 12, 2022, 4:05:01

I ran df -lP which gave me the following output:



Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1 7.6G 2.2G 5.1G 30% /
varrun 506M 108K 506M 1% /var/run
varlock 506M 0 506M 0% /var/lock
udev 506M 44K 506M 1% /dev
devshm 506M 12K 506M 1% /dev/shm
lrm 506M 40M 467M 8% /lib/modules/2.6.24-26-generic/volatile
gvfs-fuse-daemon 7.6G 2.2G 5.1G 30% /home/vmadmin/.gvfs


How can I remove the line where it says /home/"can be anything"?



I can't use df -lP | sed '$d' because the output would be



Filesystem         1024-blocks      Used Available Capacity Mounted on
/dev/sda1 7867856 3622668 3845524 49% /
tmpfs 513448 0 513448 0% /lib/init/rw
udev 507692 124 507568 1% /dev
tmpfs 513448 4 513444 1% /dev/shm

More From » command-line

 Answers
2

Reading your question now, a simple solution would be:



df -lP | grep -v '/home/' Where /home is the one you do not want to see and the -v in grep will give you the inverse of what you are searching. Basically you would be telling grep to search for all line that DO NOT have the /home with them.



If you want to be able to exclude other folders then do the following:



df -h | grep -ve "/home" -ve "/lib"



This would exclude all /home folders and all /lib folders. You can continue to add excluded folder by adding -ve and in "" the folder you wish to exclude.


[#32926] Wednesday, December 14, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
diffeah

Total Points: 78
Total Questions: 130
Total Answers: 98

Location: Peru
Member since Fri, Oct 14, 2022
2 Years ago
;