1
00:00:04,019 --> 00:00:09,450
We have just explored some additional options for find command and you know, how to, for example,

2
00:00:09,450 --> 00:00:12,060
find files depending on their sizes.

3
00:00:12,090 --> 00:00:15,840
Or you could find files that have specific permission.

4
00:00:16,050 --> 00:00:20,240
Now, let me explain you how to combine a find command and other command.

5
00:00:20,250 --> 00:00:26,340
In other words, it is possible to send result of the find command to another shell command.

6
00:00:26,550 --> 00:00:28,010
Let me show you an example.

7
00:00:28,020 --> 00:00:34,230
Let's search for files with txt extension and let's search for them in current directory.

8
00:00:34,230 --> 00:00:37,590
If there are no txt files, please create a couple of them.

9
00:00:37,710 --> 00:00:38,520
All right.

10
00:00:38,520 --> 00:00:47,520
I have some such files and I'll search for files with name that has somewhere txt like so.

11
00:00:47,520 --> 00:00:50,610
And next I'll enter one more option.

12
00:00:50,610 --> 00:00:54,120
Dash exec and here will be cut for example.

13
00:00:54,120 --> 00:00:57,110
Next comes pair of curly braces like so.

14
00:00:57,120 --> 00:01:00,390
Next comes backslash and semicolon.

15
00:01:00,390 --> 00:01:05,950
In a moment I'll explain you what this command actually does, but for now, let's simply press enter

16
00:01:06,220 --> 00:01:09,370
and see following text in this terminal.

17
00:01:09,820 --> 00:01:17,470
And actually I see here contents of all txt files that were found in current directory.

18
00:01:18,240 --> 00:01:21,090
In my case, there are several such kind of files.

19
00:01:21,090 --> 00:01:23,970
Let me actually remove this option for a moment.

20
00:01:23,970 --> 00:01:26,430
And here are those text files.

21
00:01:26,610 --> 00:01:31,770
And if I read for example this file one dot txt it seems it is empty.

22
00:01:31,770 --> 00:01:34,410
Let me read this file file three dot txt.

23
00:01:34,770 --> 00:01:43,110
I will see this text in output, but before as a result of this command I have seen text from all files.

24
00:01:44,390 --> 00:01:45,050
All right.

25
00:01:45,050 --> 00:01:48,020
Now, let me explain you the structure of this command.

26
00:01:48,080 --> 00:01:52,550
Let me actually clear terminal and go back to this command here with argument.

27
00:01:52,550 --> 00:01:54,800
It is path to specific directory.

28
00:01:54,830 --> 00:01:58,250
Next, we are looking for files with extension txt.

29
00:01:58,850 --> 00:02:04,400
Next comes exec option and here is argument for this exact option.

30
00:02:04,940 --> 00:02:07,830
It contains actually several arguments.

31
00:02:07,850 --> 00:02:10,820
Here is first argument, second and third.

32
00:02:11,380 --> 00:02:15,820
Here is the name of the command that will be executed after find command.

33
00:02:16,570 --> 00:02:21,850
And actually, in this case, Cod command will be executed multiple times.

34
00:02:22,640 --> 00:02:26,300
One time per result of the find operation.

35
00:02:27,060 --> 00:02:27,750
Recap that.

36
00:02:27,750 --> 00:02:30,710
In my case I have several txt files.

37
00:02:30,720 --> 00:02:39,330
Actually I have five txt files and that's why this cut command will be executed five times and those

38
00:02:39,330 --> 00:02:46,080
curly braces will be automatically replaced by path to corresponding files.

39
00:02:46,960 --> 00:02:50,650
It means that first command that will be executed will be cut.

40
00:02:50,680 --> 00:02:52,390
Plus this path.

41
00:02:52,840 --> 00:02:56,800
Next command will be cut, plus this path and so on.

42
00:02:57,010 --> 00:03:00,790
Cut will be executed five times in my case.

43
00:03:01,720 --> 00:03:07,210
And next you need to use additional last argument for exact option.

44
00:03:07,360 --> 00:03:10,720
Please again recap that here are three different arguments.

45
00:03:10,750 --> 00:03:16,360
Cut pair of curly braces and semicolon, but semicolon is system character.

46
00:03:16,360 --> 00:03:19,930
That's why you must use backslash in order to escape it.

47
00:03:20,350 --> 00:03:23,860
The structure of arguments for exact option.

48
00:03:24,540 --> 00:03:28,800
And again, you are able to use any other process you want.

49
00:03:28,830 --> 00:03:33,930
We have simply launched here cut process where every result of the find operation.

50
00:03:34,900 --> 00:03:37,540
For example, you could use command.

51
00:03:37,600 --> 00:03:38,530
Let's do that.

52
00:03:38,560 --> 00:03:39,370
Here will be.

53
00:03:39,820 --> 00:03:42,760
And now I see actually same result as before.

54
00:03:42,760 --> 00:03:46,120
But if I'll add here options for example LA.

55
00:03:46,780 --> 00:03:49,900
I'll see actually result of the command.

56
00:03:50,630 --> 00:03:52,340
And it starts with permissions.

57
00:03:52,370 --> 00:03:54,710
Next user group and so on.

58
00:03:55,400 --> 00:03:59,420
Also, I'm able to add some colors using here.

59
00:03:59,420 --> 00:04:01,790
Additional option dash, dash, color.

60
00:04:01,910 --> 00:04:08,540
And this option is option for command, not for exec, not for find.

61
00:04:08,780 --> 00:04:13,910
Those two options and this option are options for command.

62
00:04:14,710 --> 00:04:21,399
Actually here is the entire command that is executed for every result that is produced by find command.

63
00:04:21,519 --> 00:04:22,900
Let's press enter.

64
00:04:23,170 --> 00:04:27,280
And actually, I don't see any colors here because files are not colored.

65
00:04:27,310 --> 00:04:30,600
Let's search actually for all files and folders.

66
00:04:30,610 --> 00:04:35,620
Let's remove this name option and execute command like so.

67
00:04:35,620 --> 00:04:39,490
And now I see different colors for different folders and so on.

68
00:04:40,230 --> 00:04:40,830
All right.

69
00:04:40,860 --> 00:04:44,670
That's how you could execute additional command after find command.

70
00:04:44,670 --> 00:04:48,180
And again, structure of command is following.

71
00:04:48,300 --> 00:04:50,400
It has exact option.

72
00:04:50,640 --> 00:04:52,560
Next comes additional command.

73
00:04:52,560 --> 00:04:59,130
You want to run, for example, LHS next, if you want to iterate over all results of the find command,

74
00:04:59,130 --> 00:05:05,880
you add here pair of curly braces and finally, you add last argument for this exact option.

75
00:05:05,880 --> 00:05:07,320
Here are three arguments.

76
00:05:07,320 --> 00:05:12,510
And this last argument is semicolon and it must be escaped using backslash.

77
00:05:12,990 --> 00:05:19,110
Sometimes if you'll get an error, you should add double quotes here around curly braces and the result

78
00:05:19,110 --> 00:05:20,310
will be actually the same.

79
00:05:21,050 --> 00:05:21,620
All right.

80
00:05:21,620 --> 00:05:26,450
Let me now show you one more command and let me get back to this command that we have used in order

81
00:05:26,450 --> 00:05:33,020
to print all txt files using additional command with color option and press.

82
00:05:33,020 --> 00:05:33,800
Enter here.

83
00:05:33,800 --> 00:05:41,000
And actually, if you want to see only, let's say sizes of the files in this column and don't want

84
00:05:41,000 --> 00:05:45,980
to see all those permissions, you could use such option as.

85
00:05:45,980 --> 00:05:47,180
Let me show you.

86
00:05:47,990 --> 00:05:48,590
Print.

87
00:05:48,950 --> 00:05:55,010
It is one of the options for find command I don't use here exact option and here type following expression

88
00:05:55,010 --> 00:05:56,120
in double quotes.

89
00:05:56,270 --> 00:06:07,010
Percentage sign p percentage sign k Next space kilobytes backslash n press enter and now I see only

90
00:06:07,010 --> 00:06:09,560
files with corresponding sizes.

91
00:06:10,130 --> 00:06:17,360
That's how you are able to use own capabilities of find command in order to format results of this command.

92
00:06:17,630 --> 00:06:22,130
All right, next let me explain you what is Xargs command?

93
00:06:22,130 --> 00:06:28,460
Because we will use it in the example when you want to pipe a result of the find command to another

94
00:06:28,460 --> 00:06:29,090
command.

95
00:06:29,240 --> 00:06:31,190
Let's discuss it next by.

