ls -R /media/X | grep filename lets me search for file names, but it only prints the file name and not the directory it resides in. How can I print the file name and its directory?
|
|
||||
|
|
|
You can use the command Try
You can achieve the same results without |
|||||
|
|
This also lets you look for other conditions such as by age. |
|||
|
|
|
The currently accepted answer from @Dennis will consume a vast amount of CPU and/or IO if there are a lot of files under You will generally get faster results using the locate command (e.g. from the mlocate package). For example:
The main limitation of this approach is that the various locate packages generally will not index private home directories under ecryptfs, which may be a concern for Ubuntu users. Since the OP is using Ubuntu, I'd recommend using locate for system files, and find with some sensible limiting flags for anything stored within an ecryptfs mount. Lastly, it's worth mentioning that using find without an absolute path as the starting point may not do what the OP wants anyway. The original question was how to return a filename along with its path, so unless a relative path is acceptable, locate is again more likely to return the proper result. |
|||||||||
|
