We have just explored some additional options for find command and you know, how to, for example,
find files depending on their sizes.
Or you could find files that have specific permission.
Now, let me explain you how to combine a find command and other command.
In other words, it is possible to send result of the find command to another shell command.
Let me show you an example.
Let's search for files with txt extension and let's search for them in current directory.
If there are no txt files, please create a couple of them.
All right.
I have some such files and I'll search for files with name that has somewhere txt like so.
And next I'll enter one more option.
Dash exec and here will be cut for example.
Next comes pair of curly braces like so.
Next comes backslash and semicolon.
In a moment I'll explain you what this command actually does, but for now, let's simply press enter
and see following text in this terminal.
And actually I see here contents of all txt files that were found in current directory.
In my case, there are several such kind of files.
Let me actually remove this option for a moment.
And here are those text files.
And if I read for example this file one dot txt it seems it is empty.
Let me read this file file three dot txt.
I will see this text in output, but before as a result of this command I have seen text from all files.
All right.
Now, let me explain you the structure of this command.
Let me actually clear terminal and go back to this command here with argument.
It is path to specific directory.
Next, we are looking for files with extension txt.
Next comes exec option and here is argument for this exact option.
It contains actually several arguments.
Here is first argument, second and third.
Here is the name of the command that will be executed after find command.
And actually, in this case, Cod command will be executed multiple times.
One time per result of the find operation.
Recap that.
In my case I have several txt files.
Actually I have five txt files and that's why this cut command will be executed five times and those
curly braces will be automatically replaced by path to corresponding files.
It means that first command that will be executed will be cut.
Plus this path.
Next command will be cut, plus this path and so on.
Cut will be executed five times in my case.
And next you need to use additional last argument for exact option.
Please again recap that here are three different arguments.
Cut pair of curly braces and semicolon, but semicolon is system character.
That's why you must use backslash in order to escape it.
The structure of arguments for exact option.
And again, you are able to use any other process you want.
We have simply launched here cut process where every result of the find operation.
For example, you could use command.
Let's do that.
Here will be.
And now I see actually same result as before.
But if I'll add here options for example LA.
I'll see actually result of the command.
And it starts with permissions.
Next user group and so on.
Also, I'm able to add some colors using here.
Additional option dash, dash, color.
And this option is option for command, not for exec, not for find.
Those two options and this option are options for command.
Actually here is the entire command that is executed for every result that is produced by find command.
Let's press enter.
And actually, I don't see any colors here because files are not colored.
Let's search actually for all files and folders.
Let's remove this name option and execute command like so.
And now I see different colors for different folders and so on.
All right.
That's how you could execute additional command after find command.
And again, structure of command is following.
It has exact option.
Next comes additional command.
You want to run, for example, LHS next, if you want to iterate over all results of the find command,
you add here pair of curly braces and finally, you add last argument for this exact option.
Here are three arguments.
And this last argument is semicolon and it must be escaped using backslash.
Sometimes if you'll get an error, you should add double quotes here around curly braces and the result
will be actually the same.
All right.
Let me now show you one more command and let me get back to this command that we have used in order
to print all txt files using additional command with color option and press.
Enter here.
And actually, if you want to see only, let's say sizes of the files in this column and don't want
to see all those permissions, you could use such option as.
Let me show you.
Print.
It is one of the options for find command I don't use here exact option and here type following expression
in double quotes.
Percentage sign p percentage sign k Next space kilobytes backslash n press enter and now I see only
files with corresponding sizes.
That's how you are able to use own capabilities of find command in order to format results of this command.
All right, next let me explain you what is Xargs command?
Because we will use it in the example when you want to pipe a result of the find command to another
command.
Let's discuss it next by.