I have got a rather large file system, and let's say that I want to find all the files and directories in a certain area of my file system which contain the String ActionListeener, and to do this I want to use tree. So if I do:
tree ~/ | grep ActionListeener
The result will be:
│ │ │ └── ActionListeener.class
│ │ └── ActionListeener.java
So I now know that these files do exist somewhere a little deeper into my file system, but I have no idea about which folder contains the sub-folder, which contains the sub-sub-folder, and so on, to the files.
So really my question is, how can I get the tree command (by maybe piping the output to something else) to show me the folder and path which leads me to those particular files which contain that String?
OS Information:
Description: Ubuntu 15.04
Release: 15.04
Package Information:
tree:
Installed: 1.7.0-3
Candidate: 1.7.0-3
Version table:
*** 1.7.0-3 0
500 http://gb.archive.ubuntu.com/ubuntu/ vivid/universe amd64 Packages
100 /var/lib/dpkg/status
tree -fprints the paths relative to the current dir ($ pwd) unless you specify the path as absolute in the command e.g. assuming the pwd is/home/minime/temp/ingres/ERR5396044/, the command$ tree -fiwill return paths like./ActionListeener.class; while$ tree -fi $HOME/temp/my/data/folderwill return the paths (from anywhere) like:/home/minime/temp/my/data/folder/ActionListeener.classyou can also use$ tree -fi "$PWD"and$ tree -fi $(pwd)from the current dir. – Gergely M Aug 19 '24 at 21:06