How can I obtain the path of a file in shell?
You can use the “pwd” command to get the current working directory path, and then add the relative path or absolute path of the file to obtain the full path of the file.
For example, assuming the file name is example.txt in the current working directory, you can use the following command to retrieve the full path of the file:
pwd
This will output the path of the current working directory, for example /home/user/Documents/, and then the filename can be added at the end.
/home/user/Documents/example.txt
If the file is located in the current working directory, you can also use a relative path to retrieve the file’s location.
./example.txt