Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I'm from the Linux world where if I want to source a file I type for example:

'source /etc/profile'

How do I do this in Mac?

share|improve this question
2  
Why don't you try it in the same way? –  Gerry Mar 23 '13 at 13:54
    
I have a feeling that the question needs more work. Coming from a linux box, he should have tried this, and it didn't seem to work. Perhaps Mr. Parrish would care to explain what the circumstances were that makes think it's not working, or what he is expecting to happen. –  Sherwood Botsford Mar 23 '13 at 16:26

3 Answers 3

Terminal uses Bash by default and /bin/sh is also Bash, so source should work in most places.

source is not defined by POSIX, but it is allowed by Bash in POSIX mode or when it's invoked as /bin/sh.

The help messages for source and . are identical:

$ help source .
source: source filename [arguments]
    Read and execute commands from FILENAME and return.  The pathnames
    in $PATH are used to find the directory containing FILENAME.  If any
    ARGUMENTS are supplied, they become the positional parameters when
    FILENAME is executed.
.: . filename [arguments]
    Read and execute commands from FILENAME and return.  The pathnames
    in $PATH are used to find the directory containing FILENAME.  If any
    ARGUMENTS are supplied, they become the positional parameters when
    FILENAME is executed.
share|improve this answer

I'm using bash as my shell on my Mac and I can use "source". For example source .bash_profile

share|improve this answer

Turns out that Macs use a Bourne (like?) shell not a C shell so the way to source the file is it use '.' for example:

'. /etc/profile'

share|improve this answer
    
This is not correct. You can use source as well, as OS X uses Bash by default. Also, I'm not sure why you'd think it'd use a C shell, as most (many/all?) Linuxes use Bash or a Bourne-like shell. –  slhck Mar 23 '13 at 14:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.