Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
share|improve this question
1  
I do not yet know what your question is?. Are you trying to exclude your home folder? –  Luis Alvarado Jan 30 '13 at 15:41
    
@LuisAlvarado It was burried in the console output - I've reformatted the post and a question appeared! :) –  gertvdijk Jan 30 '13 at 15:45
    
/home/"can be anything" means /home/, followed by any string of characters. It's the last line in the first block of output. –  Flimm Jan 30 '13 at 16:11
    
df -lP | sed '$d' deletes the last line, as intended. I'm not sure why you're getting your results. –  Flimm Jan 30 '13 at 16:13

2 Answers 2

up vote 4 down vote accepted

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.

share|improve this answer
    
yes that comand "df -lP | grep -v "\/home"" done that i was wanting=) –  user127297 Jan 30 '13 at 16:00

How about this?

df -lP | grep -v "%\s\/home\/"

It filters all lines matching %, followed by single-whitespace-character and followed by /home/ by using grep.

Note to other readers: as already in the question it's important to use -P in df to keep predictable single-lined output.

share|improve this answer
    
yes it work fine. it was what i was looking for. thanks very much=). –  user127297 Jan 30 '13 at 15:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.