Search with Spotlight
- Click in the upper-right corner of the menu bar, or press Command-Space bar.
- Enter what you want to find. You can search for something like “apple store” or “emails from emily”.
- To open an item from the results list, double-click the item. Or to quickly look through the results, use the Up Arrow and Down Arrow keys.
Search by file type or location
Enable the Finder Path Bar. First, for those unfamiliar with Finder, the easiest way to see your current location in your Mac’s file structure is to enable the Path Bar in Finder’s view options. Finding files and folders on the Mac became easier when Spotlight was introduced in OS X Tiger (10.4), but locating files through the command line can be a bit tricker.
- To search by file type, use the word “kind” and the file type. For example, type “kind:folders” or “kind:audio”.
- To show the location of a file on your Mac, choose the file from the results list, then press and hold Command. The file’s location appears at the bottom of the preview. To open the file’s location, press Command-R.
- To see all the results from your Mac in the Finder, scroll to the bottom of the results list, then double-click “Show all in Finder.”
Get definitions, calculations, and conversions
Spotlight can show you dictionary definitions, calculations, measurement conversions, and more. Find out more ways to search with Spotlight.
Here are examples of what you can do:
- To get a definition, enter a word or phrase, then click the result in the Definition section.
- To get a calculation, enter something like “2+2” in the search field.
- To convert measurements, enter something like 25 lbs or “32 ft to meters”.
Find movie showtimes, weather, and nearby places
You can use Spotlight to search for movie showtimes, weather, and places near you.
Here are examples of what you can do:
- To get showtimes, enter the name of the movie that you want to see. To see what's playing near you, enter “showtimes.”
- To get local weather information, enter “weather.”
- To find restaurants near you, enter something like “places to eat,” then click a result in the Maps section.
Learn more
- Rebuild the Spotlight index on your Mac.
- Use Search on your iPhone, iPad, or iPod touch.
Spotlight features might vary by country or region.
Active8 months ago
Is there an easy way I can print the full path of
file.txt
?The
<command>
should print
Jean
JeanJean8,7021818 gold badges5959 silver badges9898 bronze badges
32 Answers
12 next
Cristian Ciupitu15.6k55 gold badges4343 silver badges6666 bronze badges
filmorfilmor21.7k33 gold badges3737 silver badges4444 bronze badges
I suppose you are using Linux.
I found a utility called
realpath
in coreutils 8.15.As per @styrofoam-fly and @arch-standton comments,
Nadjib Mamirealpath
alone doesn't check for file existence, to solve this add the e
argument: realpath -e file
2,34699 gold badges3030 silver badges4848 bronze badges
llllllllllllllllllllllllll3,26044 gold badges2323 silver badges5050 bronze badges
ZeRemzZeRemz
I know there's an easier way that this, but darned if I can find it..
GreenGiant2,99211 gold badge3434 silver badges6161 bronze badges
jcomeau_ictxjcomeau_ictx31.5k55 gold badges7272 silver badges9191 bronze badges
rogerdpack37.8k1919 gold badges145145 silver badges270270 bronze badges
Anshul GuptaAnshul Gupta
If you are in the same directory as the file:
Replace
StevenStevenfile.txt
with your target filename.1,43522 gold badges2222 silver badges3636 bronze badges
In windows you can :-
Hold shift and right click on a file which gives you can option called
This will copy the full path of the file to clipboard.'Copy as Path'
realpath yourfile
to get the full path of a file as suggested by many.
Natesh bhatNatesh bhat
I know that this is an old question now, but just to add to the information here:
The Linux command
which
can be used to find the filepath of a command file, i.e.There are some caveats to this; please see https://www.cyberciti.biz/faq/how-do-i-find-the-path-to-a-command-file/.
Lord CatLord Cat
You could use the fpn (full path name) script:
fpn
is not a standard Linux package, but it's a free and open github project and you could set it up in a minute.55.2k103103 gold badges286286 silver badges448448 bronze badges
Works on Mac, Linux, *nix:
This will give you a quoted csv of all files in the current dir:
How To Find File Path For Xampp In Os
The output of this can be easily copied into a python list or any similar data structure.
Bhargav SrinivasanBhargav Srinivasan
In a similar scenario, I'm launching a cshell script from some other location. For setting the correct absolute path of the script so that it runs in the designated directory only, I'm using the following code:
$0
stores the exact string how the script was executed.For e.g. if the script was launched like this:
$> ././test/test.csh
,$script_dir
will contain /home/abc/sandbox/v1/././test
AckqAckq
For Mac OS X, I replaced the utilities that come with the operating system and replaced them with a newer version of coreutils. This allows you to access tools like
readlink -f
(for absolute path to files) and realpath
(absolute path to directories) on your Mac. The Homebrew version appends a 'G' (for GNU Tools) in front of the command name -- so the equivalents become
greadlink -f FILE
and grealpath DIRECTORY
. Instructions for how to install the coreutils/GNU Tools on Mac OS X through Homebrew can be found in this StackExchange arcticle.
NB: The
readlink -f
and realpath
commands should work out of the box for non-Mac Unix users. Community♦
JacobWuzHereJacobWuzHere
This is explanation of what is going on at @ZeRemz's answer:
- This script get relative path as argument
'$1'
- Then we get dirname part of that path (you can pass either dir or file to this script):
dirname '$1'
- Then we
cd '$(dirname '$1')
into this relative dir && pwd -P
and get absolute path for it.-P
option will avoid all symlinks- After that we append basename to absolute path:
$(basename '$1')
- As final step we
echo
it
Community♦
![How How](/uploads/1/3/3/8/133891774/850646842.png)
7,56833 gold badges4545 silver badges7272 bronze badges
This worked pretty well for me. It doesn't rely on the file system (a pro/con depending on need) so it'll be fast; and, it should be portable to most any *NIX. It does assume the passed string is indeed relative to the PWD and not some other directory.
Russell SpeightRussell Speight
You may use this function. If the file name is given without relative path, then it is assumed to be present in the current working directory:
Hiding text in word for mac. Usage: Rainbow text for mac word.
Usage with relative path:
![How To Look Up File Path For Text File In Mac How To Look Up File Path For Text File In Mac](/uploads/1/3/3/8/133891774/300964580.png)
With spaces in file name:
RamuRamu
This is naive, but I had to make it to be POSIX compliant. Requires permission to cd into the file's directory.
Andrew MillerAndrew Miller
You can save this in your 'shell.rc' or just put in console https://iqnmqzy.weebly.com/speech-to-text-applications-for-mac.html.
function absolute_path { echo '$PWD/$1'; }
alias ap='absolute_path'
example:
ap somefile.txt
will output
Best text editor for mac. /home/user/somefile.txt
Roman Rhrn NesterovRoman Rhrn Nesterov3,09511 gold badge2323 silver badges1616 bronze badges
Will find all the links to the file with the same inode number as file.txt
adding a
-xdev
flag will avoid find
to cross device boundaries ('mount points'). (But this will probably cause nothing to be found if the find
does not start at a directory on the same device as file.txt
)Do note that
find
can report multiple paths for a single filesystem object, because an Inode can be linked by more than one directory entry, possibly even using different names. For instance:Will output:
wildplasserwildplasser32.8k66 gold badges4646 silver badges7474 bronze badges
JahidJahid14.6k55 gold badges6565 silver badges8787 bronze badges
Usually:
Alternatively, just for the current folder:
sjassjas11.6k99 gold badges6262 silver badges7272 bronze badges
I like many of the answers already given, but I have found this really useful, especially within a script to get the full path of a file, including following symlinks and relative references such as
.
and .
Which will return the full path of the
file
from the root path onwards.This can be used in a script so that the script knows which path it is running from, which is useful in a repository clone which could be located anywhere on a machine.I can then use the
${basePath}
variable in my scripts to directly reference other scripts.Hope this helps,
Dave
Dave RixDave Rix1,22811 gold badge88 silver badges1313 bronze badges
Ahmed AbobakrAhmed Abobakr
BluVioBluVio
For Mac OS, if you just want to get the path of a file in the finder, control click the file, and scroll down to 'Services' at the bottom. You get many choices, including 'copy path' and 'copy full path'. Clicking on one of these puts the path on the clipboard.
Richard SharpeRichard Sharpe
Copies the text to your clipboard and displays the text on the terminal window.
:)
(I copied some of the code from another stack overflow answer but cannot find that answer anymore)
DhruvDhruv
Lrrr3,88455 gold badges3636 silver badges6161 bronze badges
onkaronkar
In Mac OSX, do the following steps:
cd
into the directory of the target file.- Type either of the following terminal commands.
- Replace
file.txt
with your actual file name. - Press Enter
5,51111 gold badge2121 silver badges4141 bronze badges
MowzerMowzer5,99688 gold badges5151 silver badges120120 bronze badges
In mac mentioned below line works. No need to add any fancy lines.
Sanjeet kumarSanjeet kumar2,03822 gold badges88 silver badges1616 bronze badges
Beside 'readlink -f' , another commonly used command:
This also give the full path and file name at console
Off-topic: This method just gives relative links, not absolute. The
Mike Fieldenreadlink -f
command is the right one.5,3321313 gold badges5151 silver badges8989 bronze badges
Andrew_1510Andrew_15105,79588 gold badges4343 silver badges4747 bronze badges
Create a function like the below (echoes the absolute path of a file with pwd and adds the file at the end of the path:
Now you can just find any file path:
Nestor UrquizaNestor Urquiza
12 next
protected by Community♦Aug 19 '15 at 19:41
File Path Definition
Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
Would you like to answer one of these unanswered questions instead?