AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Find file in terminal on mac11/25/2023 I can do minus and then I can say things like 1h for one hour or 2h for two hours or 5d for five days or a combination like 5d6h, five days six hours. Now this minus is an actual minus not a dash like before mtime and before iname. So let's go back to the previous command, a new command so start with a dash, and say mtime, modify time, and I can now use a minus and then a time. Now I can also look for files by modification date or creation date. But also if I didn't know they were rtf's I could do anything *,, followed by test* and it will return those same three files. Now you can see I get those three files there. ![]() I can put an asterisk there, which is a wild card meaning anything followed by test.rtf. Now what if I wanted all three of those files. By the way to get these commands back quickly I just do Up arrow and it goes back to the previous command and then I can edit it. But you can make it case insensitive by hitting i instead of just name, so iname, a case insensitive name, and now it will find it. Now if I were to have specified test with a lower case t it's not going to return anything at all. It'll say it finds it in that current directory dot and slash Test.rtf. for the current directory and then do dash name, this says I want to search by name, Test.rtf. So we would expect that if we were to search for Test.rtf we would find maybe that one file that matches exactly, maybe three files that match somewhat. There's another file called Another Test.rtf, a New Test.rtf and all of that. So now that I know I'm checking in here let's look at what's in here. So I could have, for instance, said cd and then dragged the project A folder into there and done the same thing like that. You can also do the same thing with any folder. So now when I do a find with a dot it will be looking in there. Now I can check pwd to see where I am and you can see I'm there. But like, for instance, in this project folder here I can simply use the command cd, change directory, and can drag the icon here into it and hit Return. Now if you want to specify where you are you can type the entire path. That will look wherever you currently are. You can search the current directory very easily by using a dot. You can also type the entire thing out, like Users/macmost, that's your Home directory, and then you can do documents. ![]() You can do that with a tilde, that's the Shift and the key above the tab on American keyboards, and slash. So you probably want to search something like, maybe, your Home folder. It's going to find all sorts of matches you didn't expect and it's going to fill up the window will all sorts of results you don't want. Now this is a really bad idea because it's going to look in your system folder and your library folder and they are filled with tons of files. This would search your entire hard drive. So you could do, for instance, slash and that's it. The next thing you're going to type is the path to the Directory you want to search. So to use the Find command you just go into Terminal and type find. It will actually look through all the directories, look at each file, and see what matches and return the results. It's not dependent on that big index that your Mac is always updating of all your files. Now the Find command doesn't use the Spotlight index at all. But if you want to do it in a more techy kind of way in the Terminal you can use the Find command. You can also use the Spotlight menu, Command space, and search there as well. ![]() Just Command F and you would be doing a Spotlight search for the file. Video Transcript: So most of the time when you want to search your Mac for a file you just do it in the Finder window.
0 Comments
Read More
Leave a Reply. |