1 00:00:00,300 --> 00:00:09,180 Hello everyone in this video we are going to talk about a very very powerful concept and tool in our 2 00:00:09,180 --> 00:00:14,100 Linux command line which is the wild cards. 3 00:00:14,520 --> 00:00:23,040 So a wild card is simply a symbol that represents 4 00:00:25,550 --> 00:00:27,950 one or more characters 5 00:00:30,690 --> 00:00:40,200 and one of the most famous wild cards out there is the asterisk or the store and this symbol represents 6 00:00:40,860 --> 00:00:49,020 or matchers any characters any number of characters or any characters right. 7 00:00:49,550 --> 00:01:01,210 And the other famous one is the question mark which represents or matches a single character. 8 00:01:01,790 --> 00:01:07,380 So right now you might be lost and you might be asking yourself what are you talking about. 9 00:01:07,490 --> 00:01:10,560 Don't worry I will show you what I'm talking about right now. 10 00:01:10,790 --> 00:01:19,250 So right now I am on my desktop as you can see and I have many files and I also have a directory one 11 00:01:19,250 --> 00:01:23,810 by one here and this directory is initially empty OK. 12 00:01:24,970 --> 00:01:25,720 OK. 13 00:01:25,940 --> 00:01:32,610 So so far we learned how to copy files into directories right. 14 00:01:32,860 --> 00:01:33,850 But if I told you. 15 00:01:33,850 --> 00:01:35,730 Now what if you want. 16 00:01:35,730 --> 00:01:36,160 What of it. 17 00:01:36,160 --> 00:01:43,060 What if what if I ask you to copy all these files here to the directory one all the files that I have 18 00:01:43,060 --> 00:01:45,790 here to the directory one. 19 00:01:46,140 --> 00:01:46,680 OK. 20 00:01:46,690 --> 00:01:49,840 You might you would say OK this will take me a long time. 21 00:01:49,840 --> 00:01:52,100 I have to specify all file names. 22 00:01:52,270 --> 00:02:03,140 So I'll begin with one z z 3-G cats dogs even all the way until you reach this guy here. 23 00:02:03,240 --> 00:02:04,550 1G one. 24 00:02:04,750 --> 00:02:09,800 And then you specify your destination directory and you're right you can do it this way. 25 00:02:10,060 --> 00:02:16,750 But have you noticed one thing it will take you forever to include all these file names without any 26 00:02:16,750 --> 00:02:21,360 error and then copy them to the directory one instead. 27 00:02:21,490 --> 00:02:24,190 We can use the asterisk. 28 00:02:24,190 --> 00:02:31,920 So if I said C-p store directory one this will simply copy everything that I have here to directory 29 00:02:31,960 --> 00:02:32,560 one. 30 00:02:32,860 --> 00:02:34,980 So let's execute this command here. 31 00:02:35,980 --> 00:02:43,800 And let's open directory one as you can see every file on my desktop was copied to my directory once. 32 00:02:43,810 --> 00:02:46,240 So it's magic right. 33 00:02:48,130 --> 00:02:56,350 So the store represents or matches any characters any number of characters or any category of characters. 34 00:02:56,380 --> 00:02:57,450 Right. 35 00:02:58,420 --> 00:03:05,460 And if I go to my directory one now and I want to remove all my files I just have to say or am store. 36 00:03:05,620 --> 00:03:09,430 So our store will remove all the files that I have here. 37 00:03:09,550 --> 00:03:14,440 As you can see very very efficient OG. 38 00:03:14,810 --> 00:03:18,890 So let's go back to my directory one on my desktop. 39 00:03:18,890 --> 00:03:25,760 So right now as you can see I have file one the text file to the text file through the text. 40 00:03:25,760 --> 00:03:29,060 So what if I want to copy all these three files here. 41 00:03:29,360 --> 00:03:34,150 I can say C.P file store directory one. 42 00:03:34,190 --> 00:03:41,550 So if I want to copy file one text file to the text file through the text to my directory one all I 43 00:03:41,590 --> 00:03:45,840 not all I want to say is just C.P. file store directory want. 44 00:03:45,850 --> 00:03:46,720 You know why. 45 00:03:46,910 --> 00:03:54,050 Because you're saying I want to copy all the files that begins with the named file or with the characters 46 00:03:54,050 --> 00:03:58,890 file and I do not care about what foe's 5. 47 00:03:58,910 --> 00:04:04,670 So if I could just command and go to my directory one and you can see I'm done. 48 00:04:04,670 --> 00:04:05,390 Awesome. 49 00:04:05,600 --> 00:04:11,620 And now I'm go to the rectory one and remove everything that I have and now it's clean again. 50 00:04:11,700 --> 00:04:12,700 Awesome. 51 00:04:12,810 --> 00:04:19,030 So you can see it now you can you have an idea of how the asterisk wildcard works. 52 00:04:20,720 --> 00:04:25,640 And actually for example let's see here. 53 00:04:26,850 --> 00:04:33,850 If you want to copy all the files that ends with the dot the XTi. 54 00:04:34,470 --> 00:04:36,660 So here we have that XTi. 55 00:04:36,750 --> 00:04:39,010 T XTi and the XTi. 56 00:04:39,060 --> 00:04:42,510 So I would say C-p store. 57 00:04:42,630 --> 00:04:44,770 I don't care what the name with a file. 58 00:04:44,880 --> 00:04:51,160 But all I care about is that it ends with Dotti XTi and copy it to my directory 1. 59 00:04:51,600 --> 00:04:58,700 So if I go open my directory one will see file 1.60 file 2.50 and file 3.50. 60 00:04:58,890 --> 00:05:04,820 So as you can see the wildcard asterisk is very very powerful. 61 00:05:06,410 --> 00:05:10,440 And actually you can say copy all the files. 62 00:05:10,910 --> 00:05:18,990 So right now let's go to my directory once again and delete everything that I have clear my screen. 63 00:05:19,010 --> 00:05:20,740 OK right now. 64 00:05:20,840 --> 00:05:23,970 Right now I don't have anything on my directory one. 65 00:05:24,340 --> 00:05:26,660 So let's move forward. 66 00:05:26,860 --> 00:05:38,130 Let's say for example that you want to you want to copy all the files that begins with the letter. 67 00:05:38,390 --> 00:05:40,500 The lower case letters G. 68 00:05:40,500 --> 00:05:43,910 So here we have G1 G-2 and G-3. 69 00:05:43,920 --> 00:05:52,350 So all you need to say is just C-p D-Star and then directory one and this will copy all the files that 70 00:05:52,350 --> 00:06:00,000 begins with the letter G but actually so we have to go it on my desktop first and then I can do this. 71 00:06:00,050 --> 00:06:08,700 So restore directly one and this will work as you can see I have one G-2 and G-3 here. 72 00:06:09,040 --> 00:06:09,760 Awesome. 73 00:06:09,760 --> 00:06:14,550 And now I got my direct one and move everything and go back. 74 00:06:15,340 --> 00:06:15,970 Cool. 75 00:06:16,150 --> 00:06:20,280 And let's do one more. 76 00:06:20,470 --> 00:06:22,940 One more example of the asterisk here. 77 00:06:22,990 --> 00:06:33,580 So let's say that you want to copy all the files that begins with the lowercase letter N so and you 78 00:06:33,580 --> 00:06:36,060 don't care how long the file name is. 79 00:06:36,330 --> 00:06:39,580 But if you want to make sure that it ends with an e.. 80 00:06:40,060 --> 00:06:42,000 So what do I mean here. 81 00:06:42,430 --> 00:06:51,820 So here this will copy all the files that begins with the letter the lowercase letter and and ends with 82 00:06:51,820 --> 00:06:53,310 the lower case letters. 83 00:06:53,530 --> 00:06:55,270 So can you see any in any year. 84 00:06:55,280 --> 00:07:03,090 Yeah I can see number number but the number four here it ends with the letter with a letter or two I 85 00:07:03,100 --> 00:07:05,810 will not included this one will be included. 86 00:07:05,810 --> 00:07:09,040 Number one because it begins with and ends with an end. 87 00:07:09,310 --> 00:07:15,760 And this one will also be included because it begins with an end and also it ends with any. 88 00:07:15,790 --> 00:07:23,660 So if I execute this command I have to I'm expecting two files to be there which is number one and number 89 00:07:23,660 --> 00:07:24,060 three. 90 00:07:24,110 --> 00:07:28,810 Let's see as you can see number one and number three. 91 00:07:29,000 --> 00:07:30,210 Awesome. 92 00:07:30,830 --> 00:07:34,750 So that's about the asterisk wildcard right. 93 00:07:34,760 --> 00:07:41,440 Now we move our attention to the sink to the second wild card which is the question mark. 94 00:07:41,490 --> 00:07:47,340 So the question mark is different and is very useful when you when you have like a certain number of 95 00:07:47,340 --> 00:07:48,470 characters in mind. 96 00:07:48,480 --> 00:07:50,110 So what do I mean by this. 97 00:07:50,430 --> 00:08:00,890 Let's say for example that you say I want to copy all the files that begins with the uppercase or. 98 00:08:01,540 --> 00:08:04,170 OK let's see let's think of an example here. 99 00:08:06,440 --> 00:08:06,990 Yeah. 100 00:08:07,240 --> 00:08:17,140 I want to copy all the files that begins with named file and I don't care at the other what is the next 101 00:08:17,140 --> 00:08:22,670 character here but I want it to be text not the XTi directory one. 102 00:08:22,900 --> 00:08:29,960 So what I'm saying here as we know that question mark represents a single character. 103 00:08:29,990 --> 00:08:39,170 So unlike unlike the store or the asterisk which represents any character the question mark represent 104 00:08:39,230 --> 00:08:41,030 represents a single character. 105 00:08:41,030 --> 00:08:50,840 So here what I'm saying is that I want to copy all the files that have file that begins with a with 106 00:08:50,840 --> 00:08:55,900 the name file but I do not care what the other character that follows here. 107 00:08:56,000 --> 00:08:57,780 And then Datti XTi. 108 00:08:58,130 --> 00:09:06,870 So as know this will include file 1.60 file that takes the file through the text the but before I do 109 00:09:06,870 --> 00:09:11,670 this I have to I want I want to go to the rectory one and remove everything. 110 00:09:13,320 --> 00:09:21,790 And actually I want to include another file here which is called File 50 to 60. 111 00:09:21,840 --> 00:09:25,320 I will tell you why I include fine. 112 00:09:26,130 --> 00:09:38,720 So if I said C-p file that the XTi OK can you expect what this command will execute. 113 00:09:38,940 --> 00:09:44,260 OK I'll tell you right now we'll show. 114 00:09:44,280 --> 00:09:52,880 So if you go to the rectory one we can only see C-3 file which is file one file to and file three. 115 00:09:53,190 --> 00:10:01,420 So you might be wondering why it did not include file 52 for example that the XTi because it's different. 116 00:10:01,500 --> 00:10:03,330 The question mark is different 117 00:10:05,730 --> 00:10:12,390 compared to the asterisk because near all I only included one character here which is the question mark. 118 00:10:12,570 --> 00:10:19,820 So this question mark and B can represent only one character which is here 2 3 or 1. 119 00:10:19,980 --> 00:10:22,370 But here I have two characters fifty two. 120 00:10:22,590 --> 00:10:31,900 So in order to represent these two characters I have to say file star star that the XTi directory one 121 00:10:34,800 --> 00:10:39,790 and this will be filed 52 that the XTi as you can see here. 122 00:10:39,840 --> 00:10:42,060 So it is quite different. 123 00:10:42,060 --> 00:10:48,810 The question mark is very very different compared to the asterisk so let's do this one more time to 124 00:10:48,810 --> 00:10:55,240 make sure we understand the difference so I'll delete everything that I have in my directory one and 125 00:10:56,510 --> 00:11:05,870 so if he says files store the XTi this will include all the guy's file 1 file to file 3 and file 52. 126 00:11:05,900 --> 00:11:10,650 Because store here there is no restriction on the number of characters here. 127 00:11:12,000 --> 00:11:16,360 So here it will take all the four files as you can see. 128 00:11:16,710 --> 00:11:25,290 However if I delete all the guys here and then I put a question mark instead of an asterisk it will 129 00:11:25,290 --> 00:11:33,870 only take the guy's file one file to find three because I question mark and only matches or represent 130 00:11:33,900 --> 00:11:37,290 a single character OK. 131 00:11:37,550 --> 00:11:42,390 I hope you guys understand now the difference between a question mark and an asterisk. 132 00:11:42,430 --> 00:11:43,030 OK. 133 00:11:43,250 --> 00:11:46,170 Let's do more examples of the question mark. 134 00:11:46,670 --> 00:11:57,930 So let's say I want to I want to copy all the files that begins 135 00:12:00,900 --> 00:12:02,300 with an uppercase p 136 00:12:04,880 --> 00:12:07,340 and. 137 00:12:08,130 --> 00:12:08,600 OK. 138 00:12:08,620 --> 00:12:09,260 I see. 139 00:12:09,290 --> 00:12:19,450 No actually let's say that we want to copy all the files that begins with the with number and followed 140 00:12:19,450 --> 00:12:23,110 by three characters. 141 00:12:23,240 --> 00:12:28,890 OK so what do you think this command will execute. 142 00:12:28,900 --> 00:12:35,100 So if he if he if you look or if you look here we have four files that begins with number. 143 00:12:35,130 --> 00:12:36,370 Number four number one. 144 00:12:36,370 --> 00:12:36,850 Number three. 145 00:12:36,850 --> 00:12:37,330 Number two. 146 00:12:37,330 --> 00:12:45,820 However here I said that I am only interested in those files that are that begin with number and are 147 00:12:45,820 --> 00:12:49,360 followed by exactly three characters. 148 00:12:49,600 --> 00:12:54,810 So number four will not be included because four here has four characters. 149 00:12:54,820 --> 00:12:58,320 One will be included because only one has three characters. 150 00:12:58,330 --> 00:13:05,110 Three will not include included because three has five characters but two will be included because two 151 00:13:05,110 --> 00:13:06,700 has three characters. 152 00:13:06,700 --> 00:13:13,680 So in summary number one and number two are the ones that should be included. 153 00:13:14,040 --> 00:13:14,870 OK. 154 00:13:15,520 --> 00:13:25,340 So if now execute this command and I open my directly one I am expected to see two files exactly number 155 00:13:25,340 --> 00:13:28,430 one and number two awesome. 156 00:13:28,480 --> 00:13:35,350 So as you can see the question mark here represents a single character and it is very very useful when 157 00:13:35,350 --> 00:13:43,960 you have like a certain number of characters in mind right unlike the the asterisk. 158 00:13:43,960 --> 00:13:50,800 So if you actually delete this one here and you did the exact same thing but with a store. 159 00:13:51,640 --> 00:13:55,270 So what this command will execute is simply all the files. 160 00:13:55,270 --> 00:13:56,770 Number four number one number three. 161 00:13:56,770 --> 00:13:59,460 Number two because a store here represent anything. 162 00:13:59,590 --> 00:14:04,050 So here I am saying copy all the files that begins with number followed by any anything. 163 00:14:06,170 --> 00:14:08,660 And you can see 4 2 1 3 2. 164 00:14:08,810 --> 00:14:09,710 Awesome. 165 00:14:10,190 --> 00:14:10,660 OK. 166 00:14:10,700 --> 00:14:17,100 Let's leave this one here and let's do one more example before we end video. 167 00:14:18,160 --> 00:14:18,820 OK. 168 00:14:18,830 --> 00:14:24,200 Actually we can we can combine the store and the question mark. 169 00:14:24,230 --> 00:14:26,020 So how can we do this. 170 00:14:26,070 --> 00:14:27,650 It is very simple. 171 00:14:27,650 --> 00:14:44,900 So I would say copy all the files that begins with is f followed by actually no file followed by a number. 172 00:14:46,680 --> 00:14:51,140 And I don't care because this will not work. 173 00:14:51,140 --> 00:14:58,170 Let's think of another example let's think of an example that can combine the question mark and the 174 00:14:58,170 --> 00:15:01,190 asterisk. 175 00:15:01,540 --> 00:15:02,120 OK 176 00:15:04,800 --> 00:15:07,210 so this one should be not that hard. 177 00:15:07,230 --> 00:15:15,180 Ok I will say and copy all the files that begins with the letter f followed by 178 00:15:17,830 --> 00:15:30,510 1 followed by a as I think character that I'm not interested in and then L and then anything that I'm 179 00:15:30,520 --> 00:15:35,660 told that the XTi and copy this to my Reiki 1. 180 00:15:35,700 --> 00:15:37,080 So this is kind of messy here. 181 00:15:37,080 --> 00:15:44,340 What I'm saying is basically copy all the files that begins with the letter S followed by a letter that 182 00:15:44,340 --> 00:15:52,100 I'm not interested in and then followed by L and any other character until the dx d. 183 00:15:52,320 --> 00:15:59,650 So this will simply copy files one file to file three and file 52 two because all of these guys begin 184 00:15:59,680 --> 00:16:03,230 with an f followed by an a character which isn't I. 185 00:16:03,540 --> 00:16:06,830 And then all these guys also end with the extreme. 186 00:16:06,860 --> 00:16:13,680 So if I execute this command I will have four files you file one file to file three for fifty two. 187 00:16:14,100 --> 00:16:19,700 So I did this command because I just wanted you I wanted you to know that you can combine wild cards. 188 00:16:19,710 --> 00:16:26,600 The question mark and the asterisk so there are other wild cards that we did not discuss in this video. 189 00:16:26,730 --> 00:16:29,530 But we will discuss in the next video. 190 00:16:29,790 --> 00:16:37,720 So right now just practice with these two guys here the asterisk and the question mark. 191 00:16:37,790 --> 00:16:38,400 OK. 192 00:16:39,600 --> 00:16:40,250 OK. 193 00:16:40,510 --> 00:16:41,070 So.