The “find” Command
The find command is another way to get the full path of a file. Let’s see how it works:
Above, we have used the find command with the following sub-commands to get the file location:
- The -type f command helps us by looking for files.
- The -name command helps us by looking for the files in the current working directory and its sub-directories.
The above output clearly shows us the full path of the file.
How to Get the Full Path of a File in Linux
We often work with Linux files while creating shell scripts. But sometimes we need to know the full path of a file we are working on and this article will let you know how you can get the full path of a file. We have listed some methods that will help you find the location of a particular file.
But before going any further, let’s first create a file:
The above output clearly shows that file.txt has been successfully created.
Now, we will take a look at the methods that will give us the full path of a file. In total, there are 6 methods listed in this article. They include: