<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆-193  評論-715  文章-1  trackbacks-0
    看這里,關(guān)鍵是這個不一樣!執(zhí)行文件是這樣的?
    . ./.profile

    看原文:
    ======================================

    OS X: Change your PATH environment variable

    Contributor Icon Contributed by qmchenry Date Icon October 2, 2007  
    Tag Icon Tagged: Mac system administration  

    When you run a command from a UNIX or UNIX-like shell, the shell looks for the executable file using the directories listed in your PATH variable as a map. For convenience, adding directories to this environment variable means you don’t have to go hunting for a file each time you run it. Following these directions will allow you to add a directory to the search PATH.


    To change your path, you must edit the .profile file in your home directory. If you are comfortable using the vi editor, you probably don’t need to read any further. If not, then you can use TextEdit to edit your .profile.

    The default .profile is fairly short. The .profile is read when you open a Terminal window and each line is executed just like typing a command into the Terminal window. While this is handy because you can make any available command run whenever you drop to a shell, we’re concerned with changing an environment variable, PATH.

    In your editor, find the line that starts with export PATH= and give it a look to make sure it doesn’t already contain the directory path you’re going to add. Sometimes the PATH variable can get lengthy, but chances are yours just has a few directories separated by colons, perhaps something like this:

    export PATH=/opt/local/bin:/opt/local/sbin:$PATH

    There are a few things to note before making changes. The format of this line is important. The use of spaces in this command, or their lack, matters. In particular, there cannot be spaces around the equals sign or between any of the directories. If there are spaces in the directory name you want to add, you’ll need to escape the space by preceeding it with a \backslash or by putting the path in quotes (export PATH=”/path/here”).

    The export= keyword in front of that line has a very specific purpose. Defining a variable without exporting it makes it available only to the current shell, not to any subsequent shells. You may think to yourself that you don’t plan to make any subsequent shells, but this happens whenever you run a shell script. If the PATH variable was not exported, when you run a shell script, the PATH would no longer exist and it is possible that the script would fail.

    The $PATH at the end of the example above tacks the previous value of the variable (if it exists) onto the end of the PATH. By default, this will add ‘:/bin:/sbin:/usr/bin:/usr/sbin’ to the end of the PATH for you which is useful because most everything you run from the command line lives there.

    So, to add a new directory to the path, simply add it to the existing PATH line in .profile being careful to separate it from other directories there with colons and careful not to introduce unwanted spaces (everything after the space will be ignored). For example, to add the directory /mightyq/bin to the PATH shown above, the line could become any of the following examples:

    export PATH=/mightyq/bin:/opt/local/bin:/opt/local/sbin:$PATH
    export PATH=/opt/local/bin:/mightyq/bin:/opt/local/sbin:$PATH
    export PATH=/opt/local/bin:/opt/local/sbin:$PATH:/mightyq/bin

    Note that in the third example the new directory is added to the end of the PATH. You have the ability to optimize the searches your shell will do on your behalf each time you run a command by organizing your PATH logically. Putting less frequently used or really massive directories later in the path may give you a little performance boost (although these days things are pretty fast, so you have to be a little anal to really enjoy this).

    If you don’t need a directory in your path, you can reverse the process by deleting the unwanted directory still taking care to preserve the no spaces, colon separation rules.

    One last note, to test the change you made, you can use the echo command, but you need to make the shell reload the .profile first. Assuming you are in your home directory (if not, running ‘cd’ without any options will take you there), run these commands:

    . ./.profile
    echo $PATH

    The first is a neat little command in that it shows three uses or interpretations of the period in a single line. The first . is a shortcut to cause the shell to ’source’ or load the contents of the subsequent file as itself, in the manner that the shell uses when you login to a system or start a Terminal window. If you simply executed these commands like a shell script (bash .profile, for example) you would start a new shell, that shell would get the variable set, and at the end of running the .profile script, that new shell would cease to exist and the newly defined variables would be relegated to the missing sock universe.

    The second period means the current working directory. It’s not compulsory in any way in this command, but it’s habit from explaining the dots to folks, so I type it all the time now. In this context, you could also use ~/.profile as ~ explicitly means your home directory.

    The last dot causes the .profile to be hidden from view in a normal directory listing or Finder view. It doesn’t change the file in any other way, it just make it invisible and de-clutters your directories. To see hidden files, you can use ‘ls -a’ and you might be surprised by what you find.

    @import url(http://m.tkk7.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
    posted on 2011-08-04 15:08 Robin's Programming World 閱讀(968) 評論(0)  編輯  收藏 所屬分類: OS
    主站蜘蛛池模板: 亚洲国产成人a精品不卡在线 | 亚洲国产成人精品无码区在线网站 | 免费一级特黄特色大片在线观看 | 亚洲精品无码av人在线观看 | 老司机午夜免费视频| 成人看的午夜免费毛片| 国产午夜亚洲精品| 在线a毛片免费视频观看| 亚洲精品精华液一区二区 | 久久精品国产亚洲AV嫖农村妇女| 外国成人网在线观看免费视频| 亚洲AV日韩AV永久无码免下载| 99热这里只有精品免费播放| 亚洲精品乱码久久久久久下载| 久久久高清免费视频| 亚洲综合精品成人| 免费女人18毛片a级毛片视频| 一级中文字幕免费乱码专区| 亚洲综合色自拍一区| 久9这里精品免费视频| 亚洲jjzzjjzz在线播放| 国产精品久久香蕉免费播放| 永久免费观看黄网站| 亚洲大尺度无码专区尤物| 69式互添免费视频| 久久精品国产亚洲av瑜伽| 亚洲精品国产福利一二区| 免费黄网站在线观看| 亚洲人成日本在线观看| 国产乱子伦精品免费无码专区| 精品多毛少妇人妻AV免费久久| 亚洲天堂视频在线观看| 国产免费av片在线看| 亚洲天堂免费在线视频| 亚洲精品视频专区| 国产午夜无码视频免费网站| 久久狠狠躁免费观看| 亚洲国产aⅴ成人精品无吗| 国产亚洲精品美女久久久| 成人免费AA片在线观看| 国产精品hd免费观看|