How to find only the distinct paths up to the specific directory?

Asked

Viewed 45 times

1

I want to find only separate directories with the same name.

If I use the locate to find the path of a given directory :

locate mydirectory :

/var/lib/meu_diretorio/arquivo1 
/var/lib/meu_diretorio/arquivo2
/var/lib/meu_diretorio/arquivo3
/var/lib/meu_diretorio/arquivo4
/var/lib/meu_diretorio/arquivo5
/tmp/eu_diretorio/arquivo2
/tmp/eu_diretorio/arquivo3
/tmp/eu_diretorio/arquivo4

But I just want the next exit :

/var/lib/meu_diretorio/
/tmp/meu_diretorio/

How to find only the distinct paths to the specific directory ?

1 answer

0

Let’s say I know there’s a directory called vcf inside my /home, but I can’t remember where this one is and I want to find it:

$ find ~/ -type d -name "vcf"

Exit:

/home/sidon/temp/vcf

You can use it .ssh to take a quick test:

$ find ~/ -type d -name ".ssh"

Exit:

/home/sidon/.ssh
/home/sidon/.x2go/.ssh

Browser other questions tagged

You are not signed in. Login or sign up in order to post.