Linux find file by name regex1/19/2024 Here's a simple alternative using the find command. So what if you want to find all the files that people in the Developers group can view? That's difficult, right?īut don't worry. They're grouped together as Developers, QA, and others. How to Search Files that Belong to a Particular GroupĪs we saw in my previous tutorial on file permissions, there may be multiple people who share a common machine for their work. Running the above command will list all the items that are not files (directories, symlinks, and so on) in the current directory. The additional advantage is that you can prepend this -not flag before any option in the find command to find the opposite of the search query. Find all the files that do not have read-only permission The command will list all the files in the current directory that do not have read-only permission. I learned that I could do this by just prepending a -not flag with the -perm command. I searched on Google and I was surprised by the result. So, I decided to find an alternative way. Looking over 200 files to find a maximum of 5 files is a time-consuming process. I was pretty sure that it would be so low that I could count them on one hand. Out of those, I had to find all the files that didn't have read-only permission. I was working on a project that contains a huge number of minified (around 200+) files. I would like to share a weird experience that I faced in my career. You can see from the above screenshot that the find command has identified it perfectly. I created this welcome.txt file with read-only permission long ago. perm 400 Find files with read-only permission Note: If you don't know how this code ( 400) is generated and you're curious to know, please refer to the How can I remove permissions using Octal Mode? section of my Linux File Permission blog. Here's the syntax: find -perm įor example, let's assume you want to search all the files that have read-only permission in the current directory. Using -perm argument, you can search for files that have a specific permission. How to Search Files that Have Specific Permissions 5minslearn/ -type d -user aruna Find directories created by a userįrom the above screenshot, you can see that this command lists all the directories and sub-directories owned by me inside the 5minslearn directory. To filter the directories, you have to add the -type option. This basically means you can add any arguments following this to make your search a bit more effective.įor example, let's try to filter only the directories that I own. You may notice the added to the end of the syntax. The above command will list all the files owned by the user aruna in the 5minslearn directory. 5minslearn/ -user aruna Search files owned by a user You can do this by using the below command: find. Let's say you want to search all the files owned by me (my username on this laptop is aruna). The find command accepts a special argument called user which you can use to filter the files owned by a user. If you haven't read it and aren't yet familiar with find, I would highly recommend that you have a look through it and then come back here. If you're just learning about the find command for the first time, I covered the basics of file searching and explored some powerful commands to search files quickly using Linux in my previous tutorial. In this article, let's explore the more advanced version of the find command. Well, here it is! Now, it's time to take your skills to the next level. After reading it, many people requested that I write a more advanced version about the find command. Hello everyone! Thanks for your great feedback on my tutorial about the basics of the find command.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |