![]() ![]() Various options used with the find command The second line shows the response gotten by when the first line is executed, if the file is found a prompt is displayed for the user to confirm he/she wants to delete the file. The third parameter (exec) is used to signify that we want to execute another command on each of the files returned from the find command, the last parameter is the command we want to execute (in this case its the rm command) on the returned files. The first is the location to begin the search (a folder called main), the second parameter is what we are searching by which is name. In this example we pass four parameters to the find function. Rm: remove regular file './main/demo/sample.txt'? y The output gives us the path to the file.Įxample 3: find. In this example we are starting the search from a folder named main and we are searching for a directory (searching by type) with the name myDirectory. The output shows that the file was found directly in the documents directory.Įxample 2: $ find /main -type d -name myDirectory The second parameter is "-name myfile.txt" specifies what to search by which in this case we are searching by name and we are looking for a file named myfile.txt. documents which means the search should be started in the directory called documents and its subdirectories. In the example above we use the find command with only two parameters. Let's look at some examples of how to use the find command below.Įxample 1: $ find. The third and fourth parameters are optional and can be ommited. The fourth parameter is the action to be performed The third parameter is used to provide options which can be used to perform additional actions on the files that are returned from the find command. For example to search by name you pass it the value -name. The second parameter is used to determine what is to be searched (A filter). Īfter the find command the first parameter specified is the location you wish for the search to be started. Below is a general syntax of the find command: $ find ![]() The find command is a command line utility which can be used to search through a folder/directory hierachy and return files and folders which meet a certain criteria which is specified along with the find command. One such powerfull command is the find command. There are a wide range of commands understood by the linux shell but some are used more frquently than others. In order to interact with the OS through the shell the user will need to learn the commands which can be interpreted by the shell. The shell has the ability to execute a host of commands (e.g opening a file or starting up another application) and return the result back to the user. A standard way of interacting with the linux os is through a program called the shell, terminal, console or command prompt. It supports multi-tasking and multi user operations and is widely used for supercomputers and servers. Linux operating system is an open source operating system based on unix. ![]() ![]() Among all these Linux is the most popular and its free to use. There a various variants of unix, some examples include: Solaris unix, BSD, AIX, HP Unix and Linux. if it is a valid command) and executing the command. On UNIX operating systems users interact with the system through a shell or command line interface which is capable of accepting commands in the form of text, interpreting the command (i.e. It is sometimes referred to as the kernel. It consists of a set of programs that act as a link between the computer and the user. The unix Operating system is a multi-user, multi-tasking operating system. Various options used with the find command.In this article, we have explored the approach to Search for a file in Linux (Find command). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |