Is it possible to create multiple references to a file on Macintosh? - macos

What I mean is that I want the same file to exist in 2 different locations, so that when I save it in 1 location it updates in the other location. I'm running OSX Yosemite, btw. Is this possible?

If you're looking to have the file on the same computer, a symlink will do the trick:
Fire up terminal
Navigate to the directory you want to have the symlink in cd /path/to/your/file
do ln -s /any/file/on/the/disk linked-file where "linked-file" will be the name of the file you want
If you're looking to have the file on a separate computer or on a network drive, you should probably look into rsync.

Related

How to create .zshrc in Mac home directory?

I have started using Mac for the first time and I am trying to set up flutter. One of the steps is to add path in file .zshrc. For this I have to first create this file. In Windows, whenever I had to create file, I used Git Bash and use touch <filename> in any directory and the file was created. Some websites mention that touch works in Mac terminal also.
How to create this file in home directory? I tried going to the home directory using cd ~ and then touch .zshrc and touch ~/.zshrc but they don't seem to work. I also tried to save file with this extension using TextEdit but doesn't work either. I have checked Show all filename extensions in Finder > Preferences > Advanced.
So what is the way to create this file in home directory either using Finder or terminal?

Is it possible to change the Xcode's iOS DeviceSupport default folder location?

I want it to point to an external drive and save some memory on main drive.. please assist.. so far it seems that it's impossible to do so. Only Archive and DerivedData can be configured via Locations preference..
There is no such option. But you can symlink the destination with ln -s command. Something like this:
% ln -s /ExternalDrive/DeviceSupport/ ~/Library/Developer/Xcode/iOS\ DeviceSupport/
So,
Close the Xcode
Move the DeviceSupport directory to the destination where you want to store it
Symlink the new destination
Launch Xcode and check that everything works as expected
PS Check the How to Create Symbolic Links at Command Line of Mac OS X guide if you need more information about linking.

How to zip a folder in MacOS without creating an extra directory inside the zip file

I got a .zip file from my friend and it was compressed under windows, which contains three subfolders inside of it, and when I check the contents of it on my Mac terminal it looks like this:
Now I unzip this file and then zip it through terminal, and when I check the contents of that zip file it becomes like this:
I have googled how to zip on mac without creating a subfolder with same name but none of them solves the problem, my question is how to do the zip on Mac which makes the zip file looks exactly same with the initial one I got.
Thanks very very much
New edit:
I think I might did not do very well to summarize my problem, so the initial folder contains three sub-folders and all of them were created in windows environment and compressed on windows, when I tried to unzip it on my MacOS machine, the unzipped folder looks still good but when I do the compression on Mac and then view the .zip file through unzip -l xxxx.zip, it is giving me 6 files in which the three sub-folders are also treated as files. Based on my knowledge this is because in BSD systems all the folders are treated as files but in windows they are not, what I'm currently doing is to delete all these files that represent folders through "zip -d", which I know is very silly. I would be more than happy to talk about this from an operating system view with anybody who is interested in it. Thanks in advance.
For me this command works fine:
zip -j zippedFolder.zip myFolder/*
To unzip I used
unzip zippedFolder.zip
and I've got only the data from the folder.
Example: The folder I want to zip is on the desktop and he's called testFolder.
Open Terminal
cd /Users/yourUser/Desktop
zip -f myZip.zip testFolder/*

How do I access my iCloud Drive folder from Terminal?

I'm running OS X Yosemite. I would like to save my code folder in iCloud Drive so that it's automatically backed up. I need to access files from the Terminal often, so how can I access iCloud Drive from the Terminal?
cd ~/Library/Mobile\ Documents/com\~apple\~CloudDocs/
I would just add a symbolic link either to this folder or to a Source subfolder in your home directory to make working with this easier.
For example:
ln -s ~/Library/Mobile\ Documents/com\~apple\~CloudDocs ~/iCloud
and/or
ln -s ~/Library/Mobile\ Documents/com\~apple\~CloudDocs/Source ~/Source
It´s in the Library Folder of the user. The folder-name is "MobileDocuments".
It's in ~/Library/Mobile\ Documents/com\~apple\~QuickTimePlayerX/Documents/....
How to find it? You can drag a file in the finder and drop the file to the terminal, then the file path would be displayed in the terminal.
This is an awful way to get the path, I'm very curious about how to reveal it more naturally and easily and gracefully.

symbolic links work when shared to Windows or Linux (smb), but broken when shared to Mac (afp or smb)

On a Mac, I have a shared folder, ~\Documents. There are two subfolders, Data and Data_2011, the former containing folders of files from the last several years, and the latter containing symbolic links to the folders in the Data folder that have been updated since Jan 1 2011. The links were created with the standard ln -s command.
When I mount the shared Documents folder on a Windows computer, the links work. When I mount on Linux using smb, the links work. When I use these links directly on the hosting Mac, they work. However, when I mount the Documents folder from a remote Mac, the soft links are broken. To be clear, I mount the Documents folder by going to Finder > Connect to Server > afp://xxx.xxx.xx.xx/ or smb://xxx.xxx.xx.xx/Documents
Any ideas for how to get these soft links to work when shared to a remote Mac?
-Sibo
Mac OS file sharing exposes symbolic links as actual symbolic links.
If I connect one Mac to another, using either AFP or SMB, I can confirm this.
Note that symbolic links are resolved by the client -- even in a non-file-sharing case this means relative paths in symbolic links can be tricky, and in this case involving network file sharing, it means the client computer needs to be able to see the target file (the target file must also be in a folder that's shared and mounted), and the path needs to be the same.
For example, if I create a text file named "foo" in my home directory, then do "ln -s foo symlink" to create a link to it named symlink, then mount that home directory from a second computer and do "ls -l" it's shown as "symlink# -> foo", and if I cat the file I can read it. But if I create the symlink as "ln -s /Users/matt/foo symlink", then on the second computer ls -l shows it as "symlink# -> /Users/matt/foo", and cat says "cat: symlink: No such file or directory". That's because on the second computer, /Users/matt is a local home directory that doesn't contain a file named foo (and if it did, anything resolving the symlink would see the local foo, not the foo shared from the first computer).
So basically: you can use "ls -l" to see where the symlink points, and note that the client computer will resolve the symlink and try to open whatever file has that name, which may or may not be what you expected.
(Probably the reason that your test worked from your Linux machine and not your Mac is that the Linux machine has more network shares mounted or with different names, such that the symlink target name was a valid filename on the Linux machine but not the Mac.)

Resources