![pof shellto pof shellto](https://www.rehvarms.com/media/catalog/product/cache/0f8b0e94ea24b0d3a84dfbf22244d5c5/p/o/pof00693_1.jpg)
Here, the mkdir command will create a new directory named Documents in your present working directory. That way, you won't have to run the two commands individually to carry out the operation.įor the purpose of this guide, let's assume you want to create a new directory called Documents and immediately change your present working directory to it. In this case, we can bind the commands together using the AND operator, referred to as &, to get our desired result.Įxample use case: One of the most common use-cases of the AND operator in Linux is to create a new directory and get into it right away. To understand this better, consider a scenario where you wish to run two related commands such that you want the second command to run only if the first one returns a valid output. Using the AND (&) OperatorĪs you'd have probably guessed, the AND operator executes the next command in a sequence only when its previous command runs successfully. On the other hand, if it doesn't find a matching file, the command to the right will execute, and a new file with the name Document.txt will get created in your present working directory.
![pof shellto pof shellto](https://dl.kaskus.id/topwar.ru/uploads/posts/2014-01/1390275644_1.jpg)
If it finds the file, the command progression will stop-and the second command won't run. Here, the find command will look up the present working directory for the Documents.txt file. In such situations, you can run your commands in the following sequence: find.
![pof shellto pof shellto](https://www.kirkpatrickguns.com/wp-content/uploads/2021/05/1255862.jpg)
Talking about its use case, you can use the OR operator when you need to run two related commands together such that the shell executes the next command only when the previous one fails.Įxample use case: Let's assume you want to create a new file, say Document.txt, but before you do that, you want to make sure that a file with the same name doesn't already exist in the current directory.