Let's say that there are several directories and within them are several different files and I want to find a particular file location within all these directories.
How do you use pwd with ls -laR | grep xyz so that I get to know the file location based on the size within all the directories and don't have to search each one of them after finding out that the file is present somewhere in these directories.
CodePudding user response:
You can use find with size as filter:
This example will find files larger than 3k in size:
find /path -size 3k
- c: bytes
- k: Kilobytes
- M: Megabytes
- G: Gigabytes
CodePudding user response:
I think the find command is what you are looking for.
To recursively search all files that are larger than 1k bytes on /home/my-path:
find /home/my-path -size 1k
To better understand how to use find, and its size parameter (and others), see man find.
To recursively search a file called foo.txt in the directory /home/my-path:
find /home/my-path -name foo.txt
If you don't exactly know the name of the file you could use wildcards (for example, foo*.txt if the file name starts with foo and ends with .txt).
If you still can't find your file, you can remove the -name parameter and pipe the output to grep.
