Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I am trying to find text within one of bash's setup files on my mac (10.9.2).
I know the text "PIP_RESPECT" is in .bash_profile
I tried Find Any File, which apparently does not search within files.
I rebuilt my spotlight index.
I tried a finder search with visibility set to invisible, with no luck
I tried the following terminal commands:
mdfind "PIP_RESPECT"
mdfind *PIP_RESPECT*
mdfind "*PIP_RESPECT*"
mdfind '"*PIP_RESPECT*"'
which return nothing.
mdfind 'kMDItemTextContent == "*PIP_RESPECT*"cd'
which returns:
~/Library/Application Support/Firefox/Profiles/6wjt9c4s.default/sessionstore.js
which is clearly not the .bash_profile.
So what am I doing wrong?
Thank you for all your responses:
I am just trying to find the text "VIRTUALENVWRAPPER_PYTHON," if it exists, in any file, by any means.
I listed all the things I tried.
# stakolee:
$ grep 'PIP_RESPECT' ~/.bash_profile return in the terminal
returned:
~/.bash_profile:export PIP_RESPECT_VIRTUALENV=true
grep: return: No such file or directory
grep: in: No such file or directory
grep: the: No such file or directory
grep: terminal: No such file or directory
so the top return is what I want, thank you. I would give you a check mark, but it does not seem to allow check marks in comments.
#Mark Setchell
Easy Find finished a lot faster, but you have made me realize I need to learn more about grep.
I awarded the checkmark to:
# Thomas Tempelmann "find any file guy": sorry, I didn't mean to dis your app, but the Easy Find app did work, after i changed the settings to scan all files
I clearly have more to learn, thank you all, again.
I am not sure from your question if you are trying to say "How do I make Spotlight find a file?" or "I want to find a file containing PIP_RESPECT and I don't care how".
If the second, you can search through every file on your Mac from the terminal like this:
sudo find / -type f -exec grep PIP_RESPECT {} /dev/null \; 2> /dev/null
It will take some time to run! It says... starting at the root (top) of the filesystem, find everything that is a file (not directory) and look in every file (with grep) and see if you can find PIP_RESPECT and print the name of the file if you can and throw away error messages.
If you only want to search in your own login directory and below, it will be quicker and easier to do this (thanks to #I'L'I):
find ~ -type f -exec ....
Author of Find Any File here.
I tried Find Any File, which apparently does not search within files.
Right, it doesn't. But it documents that clearly both on the web page. May I quote:
Contrary to Spotlight, [...], but not for file content (use Spotlight or EasyFind for that).
And if you read a bit further down:
Alternatives to Find Any File
If you like to search for data inside files, and Spotlight doesn't do it for you, have a look at EasyFind by DEVONtechnologies [...]
If you want to search for specific text in a large set of files inside a directory, I recommend TextWrangler.
Also, the reason why Spotlight (including mdfind) doesn't find anything is that Spotlight implicitly ignores anything in the System folders. It won't ever find anything in there.
Hope that helps.
Related
I'm currently practicing basic Shell Commands in WSL, Windows Subsystem for Linux (I do not have a linux system but I want to get familiar with commands).
I start a bash session on the command prompt window and navigate to my desktop using cd . In desktop I noticed that after using ls -lF some files with the prefix ~$ appear, such as: '~$executable.x'* or '~$file.txt'
These files are not currently present under the desktop directory, but I was able to remember that they were at one point (varying from a week to months ago).
When I do the same process in powershell windows (not using linux commands) I noticed that files displayed match the desktop and no extra files are listed.
I was wondering if anyone could explain what ~$ means in this context? my intuition is telling me they are backed up files that are somehow hidden in the desktop. After googling, all I could find is that ~ reefers to the home. I also understand that $ is the default prompt symbol for the bash shell when it is waiting for me to type something, but I'm still confused on why it would show up as a prefix for the name of a file.
Hope I made my question clear.
I'm currently reading "Linux® Command Line and Shell Scripting BIBLE" by Blum and Bresnahan but I could not find an answer there, this is my last resource after many googling attempts. Any other source for more information on the topic would be helpful.
On Windows, files that start with ~ are used for hidden files. More specifically,, the prefix ~$ are often used as backups for programs, should they crash before writing updates to a file (e.g. Microsoft Word, etc.)
From Wikipedia:
The tilde symbol is used to prefix hidden temporary files that are created when a document is opened in Windows. For example, when you open a Word document called “Document1.doc,” a file called “~$cument1.doc” is created in the same directory. This file contains information about which user has the file open, to prevent multiple users from attempting to change a document at the same time.
See: Why does Word make temporary files?
Relevant superuser question: https://superuser.com/questions/405257/what-type-of-file-is-file
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
I'm new to using mac. Could someone please help me out with the terminal commands?
cd to jump into folders right?
i tried this but it isn't working for a folder in my desktop.
Basically, I want to enter a folder on my dekstop and then go to another folder inside that. how do i do it?
The Terminal starts in your HOME folder normally. So, type
ls
to list the files and you will see the same folders and files you see when you go to HOME in the Finder. So, you will see Desktop, so now type
cd Desktop
ls
and you will see all the folders and files on your desktop. If you want to go into one called Freddy Frog now, you will need to put double quotes around it to make sure the space between Freddy and Frog is kept and it doesn't think you want to go to a folder called Freddy then one called Frog. so type
cd "Freddy Frog"
ls
and you can now go to the "Spiders from Mars" directory in there with
cd "Spiders from Mars"
ls
In general, you can just start typing the name of the folder you mean and press TAB and it will guess what you mean. So, if you start a new Terminal and type:
ls
you will see the files in your Home directory. Now type:
cd Desk<TAB>
and it will show you what it guesses you mean. That's called filename completion. If you want to know where you are currently located, use:
pwd
which will print the working directory.
If you want to return to your HOME directory at any time, just type:
cd
Two other tips for you if you are learning your way around...
Firstly, if you want Finder to open and display the directory you are currently in in the Terminal, you can run:
open .
Secondly, when Finder opens, you can turn on the Path bar at the bottom of the window by typing:
Command+Option+P
I have shown it in red - no idea why Apple ships with it turned off by default - probably explains why most Mac users I have met generally have no idea where their files are and don't know the difference between copying and moving files!
To change directory to say /usr , the command should be cd /usr
i.e. cd followed by the absolute path of the directory. For relative paths use cd ./usr where the directory usr is in your current directory.This link gives complete documentation of cd command.
Use the change directory command:
using relative paths cd ./relative/path/to/directory
using absolute paths cd /absolute/path/to/directory
IMPORTANT: do not to forget the space after cd and before the path!!!!!
On Windows, the space isn't needed for some reason...
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I'm currently trying to recursive copy a hidden directory using this command
cp -r ../openshiftapp/.openshift .
It is not working.. what can be wrong?
On OS X you should use -R rather than -r. The man page (on Snow Leopard 10.6.8) says:
Historic versions of the cp utility had a -r option. This implementation supports that option; however, its use is strongly discouraged, as it does not correctly copy special files, symbolic links, or fifo's.
The recursive option for the cp command would be used on directories, not files. The documentation states:
-R, -r, --recursive
copy directories recursively
The OSX docs have more info, but don't suggest that the option can be used with files. Instead, it still mentions their use for copying directory contents:
-R If source_file designates a directory, cp copies the directory and the entire subtree connected
at that point. If the source_file ends in a /, the contents of the directory are copied rather
than the directory itself. This option also causes symbolic links to be copied, rather than
indirected through, and for cp to create special files rather than copying them as normal files.
Created directories have the same mode as the corresponding source directory, unmodified by the
process' umask.
In -R mode, cp will continue copying even if errors are detected.
Note that cp copies hard-linked files as separate files. If you need to preserve hard links, consider using tar(1), cpio(1), or pax(1) instead.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I'm developing sites on mac and every time I create some folder (or file in that folder) .DS_Store is created in that folder.
How to prevent creating .DS_Store file ?
Please install http://asepsis.binaryage.com/ and then reboot your mac.
ASEPSIS redirect all .DS_Store on your mac to /usr/local/.dscage
After that, You could recursively delete all .DS_Store from your Mac.
find ~ -name ".DS_Store" -delete
or
find <your path> -name ".DS_Store" -delete
You should repeat procedure after each major Mac update.
NOTE: "Asepsis is no longer under active development and supported under OS X 10.11 (El Capitan) and later."
Here's a comprehensive review of your options. Asepsis (the second solution mentioned) seems to be what you're looking for, it re-routes .DS_Store creation to a unified cache instead of being located on every folder.
Its is possible by using mach_inject. Take a look at Death to .DS_Store
I found that overriding HFSPlusPropertyStore::FlushChanges() with a
function that simply did nothing, successfully prevented the creation
of .DS_Store files on both Snow Leopard and Lion.
DeathToDSStore source code
NOTE: On 10.11 you can not inject code into system apps.
Open Terminal. Execute this command:
defaults write com.apple.desktopservices DSDontWriteNetworkStores true
Either restart the computer or log out and back in to the user account.
for more informations:
https://support.apple.com/en-us/HT208209
Put following line into your ".profile" file.
Open .profile file and copy this line
find ~/ -name '.DS_Store' -delete
When you open terminal window it will automatically delete your .DS_Store file for you.
this file starts to appear when you choose the system shows you the hidden files: $defaults write com.apple.finder AppleShowAllFiles TRUE
If you run this command disapear
$defaults write com.apple.finder AppleShowAllFiles FALSE
Use terminal
the function
find ~/ -name '.DS_Store' -delete
, removed the .DS store files temporarily. But am not sure , whether the files will came back on the Mac.
Also i noticed something peculiar, the "DS_Store" start coming to the Mac after installing 'ATOM'. So guys please make it sure to scan properly your third party software before installing them.
Best
If you want the .DS_Store files to become invisible (they still exist but can't be seen) then run the following command in the "Terminal" window:
defaults write com.apple.finder AppleShowAllFiles FALSE; killall Finder
This will set the system default to stop showing these files on your Desktop and elsewhere. It will also restart the Finder in order to make this change visible (especially on your Desktop).
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I'm developing sites on mac and every time I create some folder (or file in that folder) .DS_Store is created in that folder.
How to prevent creating .DS_Store file ?
Please install http://asepsis.binaryage.com/ and then reboot your mac.
ASEPSIS redirect all .DS_Store on your mac to /usr/local/.dscage
After that, You could recursively delete all .DS_Store from your Mac.
find ~ -name ".DS_Store" -delete
or
find <your path> -name ".DS_Store" -delete
You should repeat procedure after each major Mac update.
NOTE: "Asepsis is no longer under active development and supported under OS X 10.11 (El Capitan) and later."
Here's a comprehensive review of your options. Asepsis (the second solution mentioned) seems to be what you're looking for, it re-routes .DS_Store creation to a unified cache instead of being located on every folder.
Its is possible by using mach_inject. Take a look at Death to .DS_Store
I found that overriding HFSPlusPropertyStore::FlushChanges() with a
function that simply did nothing, successfully prevented the creation
of .DS_Store files on both Snow Leopard and Lion.
DeathToDSStore source code
NOTE: On 10.11 you can not inject code into system apps.
Open Terminal. Execute this command:
defaults write com.apple.desktopservices DSDontWriteNetworkStores true
Either restart the computer or log out and back in to the user account.
for more informations:
https://support.apple.com/en-us/HT208209
Put following line into your ".profile" file.
Open .profile file and copy this line
find ~/ -name '.DS_Store' -delete
When you open terminal window it will automatically delete your .DS_Store file for you.
this file starts to appear when you choose the system shows you the hidden files: $defaults write com.apple.finder AppleShowAllFiles TRUE
If you run this command disapear
$defaults write com.apple.finder AppleShowAllFiles FALSE
Use terminal
the function
find ~/ -name '.DS_Store' -delete
, removed the .DS store files temporarily. But am not sure , whether the files will came back on the Mac.
Also i noticed something peculiar, the "DS_Store" start coming to the Mac after installing 'ATOM'. So guys please make it sure to scan properly your third party software before installing them.
Best
If you want the .DS_Store files to become invisible (they still exist but can't be seen) then run the following command in the "Terminal" window:
defaults write com.apple.finder AppleShowAllFiles FALSE; killall Finder
This will set the system default to stop showing these files on your Desktop and elsewhere. It will also restart the Finder in order to make this change visible (especially on your Desktop).