The “ls” Command
Yet another method is to use the ls command. If a directory is passed as an argument, then it lists all the files and folders that are located inside that directory. But if a file name is passed along with the pwd command, then the command shows us the file location. See the following:
We can see above that the full path of the file is displayed on the screen.
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: