welcome back to the adventure this is Adam and today we're creating another
smart command in a previous video we give defined in sort commands to search
through the contents of a text file now we will incorporate those commands into
a batch file first let's create a simple file using the find command
this batch file will display all the records from the phb k text file that
contain a string we specify as the parameter the parameter is case
sensitive so typing it in all caps rendered null results but typing cons
and lowercase returned all of our results for the consultants in the phone
book file now let's create a second file that will do a compound
this batch file will accept two parameters the results of the first find
command are passed to the second find command to further filter the output say
we want to find all of the consultants with the last name Jones one last simple
file to create will be one that displays the result except the ones containing a
string you specify
this batch file requires one parameter that is the string you don't want to see
like so
so that is going to filter out all of the phone numbers with the area code
beginning in 747 something we may want to do is use one batch file to carry out
the command than another one way to do this is to chain the batch files which
we'll look at now another option is to use the call command which we'll discuss
in a later video
the first is command checks whether the first parameter typed with the show
command is set the equals equals compares two strings to see if they are
identical if percent one is the same as except then show except dot that will be
carried out the second parameter percent to you type with the show command is the
string to search for it is the single parameter required by show except that
the second if command checks whether the first parameter typed with the show
command is end if it is then show and dot that is carried out the second and
third parameters % 2 + % 3 are the two strings to search for if the first
parameter is not accept or and then the find command is carried out to perform
the search
let's take a look at how that works
there we go so it used show and dot bat and past the two parameters cusp for
customers and the last name Jones so we get the one matching result from the
phone book file James Jones that finishes our new smart command thanks
for stopping by see you next video