Active1 month ago
'ls' can show the file name, e.g
'pwd' show current folder full path, e.g
Is there a command can put them together, would be able to show:
The Hosts file in Windows 10/8/7, is used to map hostnames to IP addresses.This Hosts file is located deep down in the Windows folder. It is a plain text file, and the size of the original default. How to copy a file path on a Mac This is obscure, but I ran across this recently and thought it might help someone else out. I frequently need to copy the path to a file on my Mac or on a server, so that I can include that path in documentation or in a support email with a customer. And can be pasted into a text document or an email.
Rob LRob L
7 Answers
From here:https://stackoverflow.com/a/4031502/804713
macports and homebrew provide a coreutils package containing greadlink (GNU readlink). credit to Michael Kallweitt post in mackb.com
brew install coreutils
The best answers are voted up and rise to the top. Unanswered; How to show full path of a file including the full filename in Mac OSX terminal? Ask Question. Up vote 32 down vote favorite. 4 'ls' can show the file name, e.g. Ls config.inc.php config.inc.php 'pwd. How to expand to full path file name according to path variable in. The path for each file is listed under the file name and can be copied by right-clicking on the file name or path for a file and selecting “Copy path to clipboard” from the popup menu. Finally, you can also use the “Save As” command to find out the path of the currently open file. Did you want to see the full path in the window listing all folders and files, or in the title bar? To see the full path in the window, right click on the header bar (where the column headers are.
greadlink -f file.txt
Community♦
stephenbezstephenbez
There are many ways to do that; here is one example that may work for you:
If you want more examples, there are a bunch on this post at stackoverflow.
Community♦
yoonixyoonix
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.
61433 gold badges1010 silver badges1919 bronze badges
You can also use the 'find' command for listing all files with complete path:
or just the following:
MireiaMireia
Didn't like any of the given solutions so I made up my own based off of https://stackoverflow.com/a/22684652/953327
Create alias which simply is a function call that combines
pwd
and ls $1
. You can then add this to your .bash_profile
if you choose.Example of use:
I chose
lsf
for 'list full' or 'list file', makes sense to me but feel free to modify.Update (Thanks @santiago-arizti) To be able to use this with relative paths (e.g.
lsf ../../readme.md
) FGregFGreg
I wanted more than you needed, I needed to be able also to ask about files in a relative directory, like
../../readme.md
, and the result should be something like /Users/santi/readme.md
So I created a (executable) script in a folder that is part of the
$PATH
called lsf
with the following contents:So you can use it like this:
No parameters gives you warning
Fake directory gives you warning (because of
dirname
)Fake file but real directory doesn't warn (you can add validation if you need)
santiago ariztisantiago arizti
The following will find a file within the working directory that matches
file.txt
and return its absolute pathmarkmark
Not the answer you're looking for? Browse other questions tagged macoscommand-line or ask your own question.
It can be hard to keep track of all the dataUse Data Crow to Organize & Manage All Your Stuff [Windows]Use Data Crow to Organize & Manage All Your Stuff [Windows]Here at MUO, we've always offered you tools to organize your things. For example, Justin introduced you to Qigga for organizing academic papers, and Jessica offered up some tools for organizing PDF files. But what...Read More on your computer, which is why the built-in Windows search function can come in so handy. But have you ever found it doesn’t always turn up the result you want?
This might be because you’re trying to search inside the contents of a file. By default, Windows won’t look at the internals of every single file when performing your search. However, there is a way to enable this.
Not only can the Windows search be improved, but there are third-party programs that might offer you better search experiences3 Ways To Enhance Google Chrome's Custom Search3 Ways To Enhance Google Chrome's Custom SearchIn terms of browsing speed and flexibility, Google Chrome has long been my favorite browser. A lot of this speed comes from the browser itself. The remaining speed is the result of its extensibility. Our...Read More. Be sure to drop into the comments section afterwards to offer your own advice.
Using Windows Search
How To Look Up File Path For Text File In Macro
The search function built into modern versions of Windows is much better than it used to be on older operating systems8 Ways You Can Still Use Your Old Windows XP Hardware8 Ways You Can Still Use Your Old Windows XP HardwareMicrosoft is killing support for Windows XP this April. If you have a computer that runs Windows XP, you should seriously consider upgrading the operating system, or finding new uses for the computer's hardware.Read More, offering a powerful search that is usually great at finding the file you need. However, there might be the occasion where the file you seek doesn’t come up. This is because, by default, the search isn’t looking inside the contents of every file type.
It’s time to change that and make the Windows search even better. First, perform a system search for indexing options and select the relevant result. In the new window that opens click Advanced and then switch to the File Types tab. Here you will find a list of most file types on your system, right down to the really obscure ones. If it isn’t listed then you can add it using the text box and hitting Add.
If you click something common from the list, like doc, then you’ll notice that the file is indexed with the Index Properties and File Contents option. This means that Windows search will look inside these types of files when you input your search query. However, click a more obscure file typeHow To Open Strange File Types In WindowsHow To Open Strange File Types In WindowsComputers know thousands of different file formats. Sometimes, both you and Windows are clueless as to how to open a strange file. Here is how you can figure out how to open those files.Read More and it’ll likely just be set to Index Properties Only.
If you know what the file type is that you’re after, find it on the list and switch it so that it’s set to index the properties and file contents. Once done, click OK.
You can also force Windows to always search within the file contents for specific folders on your computer. First, navigate to the folder of your choice (it can be top level like Computer or something lower down like Documents). When there, press Alt and from the menu that appears go to Tools > Folder options…. Switch to the Search tab and select Always search file names and contents and then press OK.
While these methods will make your search more useful, it’s worth noting that they can slow down the speed at which you’ll get your results. The more file types that have their contents indexed and the more folders searched, the longer it’ll take. If you notice significant slowdown then it might be worth cutting back on your indexing and only enabling the more obscure searches when necessary.
Agent Ransack
File Extension
We’ve rounded up a list of Windows search alternatives6 Awesome Alternatives to Windows Search6 Awesome Alternatives to Windows SearchDoes a Windows system search take you longer to find things than a manual search? You're not alone. Let us show you more efficient Windows search tools.Read More in the past, but these don’t specifically search file contents. If the Windows search isn’t for you then there is a third-party tool called Agent Ransack at your disposal. This isn’t the only program available, but it’s potentially the best due to its system compatibility, list of features and lack of price tag.
Agent Ransack comes from Mythicsoft and is a free alternative to their FileLocator Pro program. You can search your entire system for containing text and you can also specify parameters like file size and date modified. It has an incredibly simple and easy to use interface, which is quite possibly easier to navigate than the actual Windows search.
The tool will tell you exactly which line your search term appears on within a file (along with how many times it’s contained within) and it’ll give you the search results super quickly. Of course, if you’re searching your entire system then it might take a while, but you can narrow down to folder searches if you need to cut out some of the excess.
Souped-up Searching
These methods will get your system searches to be more thorough, allowing you to dig deep through masses of data and scout out that specific file that you need.
File Path References
Whether you prefer the built-in Windows search or a third-party alternative, both will get the job done well. And with Windows 8 search being the most powerful yetHow To Search Better & Faster On Windows 8How To Search Better & Faster On Windows 8Windows 8 search features are quite robust once you get used to them. You can use modern and desktop approaches to search your computer and the Internet. Find out more!Read More, we’re looking forward to see what Microsoft will come up with for Windows 10. Since Cortana appeared on the Windows 10 desktopCortana Arrives on the Desktop & Here's What She Can Do for YouCortana Arrives on the Desktop & Here's What She Can Do for YouIs Microsoft's intelligent digital assistant as competent on the Windows 10 desktop as she is on Windows Phone? Cortana has a lot of expectation on her shoulders. Let's see how she holds up.Read More, we’re already seeing a glimpse of what is possible.
What methods do you use for searching the contents of your files? Do you have a program that you recommend?
Explore more about: File Management, Windows 10, Windows 7, Windows 8, Windows 8.1, Windows Search.
- Thank you very much.. I found what I searched for.
- This worked for me in searching for .pdf files. I thought I didn't have the file, then I found it the manual way. After that, I found this article and then went into Windows Explorer, Organize, Folder and Search Options, Search, and then checked the box for'Always search file names....'
After checking the box, I used the Windows 7 Search function again, and the file cam up.
Thanks! - THIS DID NOT WORK THANKS.
- Hi Devon,I just posted a comment. You'll see it when my post is published. Basically, follow the directions for updating the Search options in Windows Explorer. Feel free to email me if you need more info, thanks.
- Here's a puzzle: I searched one particular directory of OpenOffice Writer files on my hard drive with the search specification that they contain one particular word. The search found 40 files that contained that word. The problem was that there were several other files that also contained that same word in that directory, but the search didn't find them. I checked to see if those incidences of that word were somehow obstructed, such as being in a weird font, being a graphic instead of text, being enclosed in a frame, or other oddity. They weren't. They were entered as plain and normal as all the other occurrences of that word that was found in the rest of the files. The OpenOffice Writer file finder didn't identify those files as having that word either. Big mystery.
- Good article. you could also use KrojamSoft FilesSearch, it helps too.
- Good ideas. Try using KrojamSoft FilesSearch, it helps a lot too
- Great article. It helped me find a Proxy Server redirect that had been made by a malicious download. I had not seen this for many years, so it just did not dawn on me that it might be why I was getting redirected.The rest of the article is good information also. Keep up the good work.
- Completely useless. Instructions bear no relation to reality.
- I found out recently notepad++ has a find in files feature (not sure if it is new or I just never bothered to look at that tab in the search options before)
- It crashes the program. I just tried that.
- You could try using KrojamSoft FilesSearch
- grepwin works pretty well for me in windows 10. too bad Microsoft forgot how to search after windows xp. that search worked perfectly. idiots.
- AstroGrep is fast, easy to use, and light weight. I hate I have to say this, but yes it searches in files. I also really like the preview window with highlighting. Regex is part of it or just plain searches like *.docx. Free and open source. http://astrogrep.sourceforge.net/screenshots/
- This is beyond absurd! The old Windows systems simply offered the option in their search window! What a ridiculous hassle!
- Nope, doesn’t help. Indexer is off and Windows will not search in some file types. For example, it find stuff in .txt file, but not .cpp files.
- I like Lookeen! You could compare it to Copernic, but the free version is much better.
(www.free.lookeen.com / http://www.lookeen.com). Really neat tool! - I have used Everything for years, but am always looking for something if it is better.
- Everything is the King
- I'm still using Google desktop (I carefully kept the installation file on a USB thumb) and it's quite good. Never understood why Google removed it...
- Everything does not search in contents.
X1 Search 8 is my best. - I have found a program called, 'SearchEverything' and am totally impressed. It not only searches for the data requested but also finds iterations of the search word(s).
- I now use agent ransack now, but have used DOCFETCHER
http://docfetcher.sourceforge.net/en/index.html - My vote goes to 'Everything', small footprint and superfast searches.
Once you have the files located it is easier to check contents anyway... - Copernic is my favorite for the speed, options, and presentation of the results.
- I use Zabkat's Explorer2 as a file manager (see http://www.zabkat.com/). A simple Ctrl+F allows me to search filenames or file content within whatever folder I want, and with a zillion parameters available. Explorer2 is so much more advanced than Windows Explorer. It is worth the $30 license (free 21-day trial).
- X1 desktop search... simply the best.
- Agree! And the latest version widens the gap with significant improvements. It won't do Thunderbird EMail - but that's not a big deal because the built-in search in TBird is fully content-indexed, fairly fast, and 'good enough'
- Sounds like a great tool and it comes with a free trial. We do focus on free solutions as much as possible.What would you say does X1 offer that isn't covered by the free alternatives?
- I use Copernic desktop search pro. It will search contents of emails (including Thunderbird/Eudora) as well as PDF file content for readable text. It will search in all drives including USB attached. It is Not free but there is a free trial version available before you commit. Another good paid program is X1 but it does not do emails other than outlook I believe.
- Thanks for the advice, Mike!What does X1 offer that the free alternatives don't? I'd be curious for whom this is worth the investment. People who don't use SharePoint and don't have to search within Emails probably find the same value in Agent Ransack. What do you think?
- Does 'everything' provide content search too ?
- nope... no content search
- I take it that's the 'Everything Search Engine'?If so, I completely agree! http://www.voidtools.com/
- I have tried many similar apps but my favorite is Everything. It is small, instant and portable.
- Oh yes.....I use 'Everything' everyday. Parked in my task bar.
- 'Everything' has turned out to be one of the most valuable programs I have, I use it for a myriad of things where rapid search is a supporting process, I keep it running in my task bar as well......it really is the best.
- I have everything too and its great, but it doesn't provide content search.
- Thanks for the tip, Najib and thank you for the heads-up Eric!Here's a link to the Everything search engine for those who'd like to try it: http://www.voidtools.com/
- I've been using Agent Ransack for years and I love it. It's way better than the windows search and you can even enable it to load when you press ctrl-F