The “dirname” Command
Another interesting option is the dirname command. It takes the full path of a file, strips the file name from the path, and displays the rest on the screen. Check out the implementation and output below:
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: