`

Linux Command: source

 
阅读更多

NAME

source - Evaluate a file or resource as a Tcl script  

SYNOPSIS

source fileName

source -rsrc resourceName ?fileName?

source -rsrcid resourceId ?fileName?

DESCRIPTION

This command takes the contents of the specified file or resource and passes it to the Tcl interpreter as a text script. The return value from source is the return value of the last command executed in the script. If an error occurs in evaluating the contents of the script then the source command will return that error. If a return command is invoked from within the script then the remainder of the file will be skipped and the source command will return normally with the result from the return command.

The -rsrc and -rsrcid forms of this command are only available on Macintosh computers. These versions of the command allow you to source a script from a TEXT resource. You may specify what TEXT resource to source by either name or id. By default Tcl searches all open resource files, which include the current application and any loaded C extensions. Alternatively, you may specify the fileName where the TEXT resource can be found.

source命令:
source命令也称为“点命令”,也就是一个点符号(.),是bash的内部命令。
功能:使Shell读入指定的Shell程序文件并依次执行文件中的所有语句
source命令通常用于重新执行刚修改的初始化文件,使之立即生效,而不必注销并重新登录。
用法:
source filename 或 . filename
source命令(从 C Shell 而来)是bash shell的内置命令;点命令(.),就是个点符号(从Bourne Shell而来)是source的另一名称。

source filename 与 sh filename 及./filename执行脚本的区别在那里呢?
1.当shell脚本具有可执行权限时,用sh filename与./filename执行脚本是没有区别得。./filename是因为当前目录没有在PATH中,所有"."是用来表示当前目录的。
2.sh filename 重新建立一个子shell,在子shell中执行脚本里面的语句,该子shell继承父shell的环境变量,但子shell新建的、改变的变量不会被带回父shell,除非使用export。
3.source filename:这个命令其实只是简单地读取脚本里面的语句依次在当前shell里面执行,没有建立新的子shell。那么脚本里面所有新建、改变变量的语句都会保存在当前shell里面

分享到:
评论

相关推荐

    Linux for Developers: Jumpstart Your Linux Programming Skills

    He presents essential skills for both Linux command line and GUI environments, introducing text editors and other tools for efficient coding. Building on this knowledge, Rothwell introduces ...

    qt-opensource-linux-x64-5.12.12.run

    qt-opensource-linux-x64-5.12.12.run Qt(官方发音 [kju:t],音同 cute)是一个跨平台的 C++ 开发库,主要用来开发图形用户界面(Graphical User Interface,GUI)程序,当然也可以开发不带界面的命令行(Command ...

    Arm ping command package can compile and transplant source code.zip

    ping源码 亲测~完美安全可靠,推荐使用 Arm ping command package can compile and transplant source code

    qt-opensource-linux-x64-5.12.12.zip

    qt-opensource-linux-x64-5.12.12.zip Qt(官方发音 [kju:t],音同 cute)是一个跨平台的 C++ 开发库,主要用来开发图形用户界面(Graphical User Interface,GUI)程序,当然也可以开发不带界面的命令行(Command ...

    Linux for Developers

    He presents essential skills for both Linux command line and GUI environments, introducing text editors and other tools for efficient coding. Building on this knowledge, Rothwell introduces scripting...

    ext2command for linux

    ext2 ext3 ext4 command for linux. use C source codes

    (winmerge for linux)grimmdp-winmerge-1bd708f4cf72.zip

    WinMerge 3 is LGPL licensed open source software. GPL license is included in file COPYING and LGPL license is in file COPYING.LESSER. More information about these licenses is available at ...

    Android代码-dlib-android-app

    Grap the source $ git clone https://github.com/tzutalin/dlib-android-app.git Features Support HOG detector HOG Face detection Facial Landmark/Expression Demo Build Android app Open ...

    crtmpserver源码

    In order to get the source code, issue the following command: svn co --username anonymous https://svn.rtmpd.com/crtmpserver/trunk crtmpserver When it asks for password, hit Enter key Compile the ...

    squashfs1.3r3.tar.gz

    be created with for example the linux-2.4.19 source. Appending the linux-2.4.20 source will create a filesystem with the two source trees, but only the changed files will take extra room, the ...

    cheat_sheet.html

    The Ursina Engine is available for Windows, Mac and Linux with the source code available on GitHub under the MIT license. To get started with the Ursina Engine you need to have Python 3.6 or later ...

    Linux Essentials 2nd 第2版 无水印pdf 0分

    An open source operating system, Linux is a UNIX-based platform that is freely updated by developers. The nature of its development means that Linux is a low-cost and secure alternative to other ...

    libstdc++.so.6.0.17(x64)

    [root@localhost TMP]# ./qt-opensource-linux-x64-5.2.1.run [root@localhost TMP]# /usr/bin/xdg-open: line 402: htmlview: command not found Failed to load core: /opt/Qt5.2.1/Tools/QtCreator/lib/qt...

    stardict command envirment

    stardict command envirment linux stardict source code

    Linux for Programmers and Users

    Offering full coverage of Linux in one source, this book documents the most commonly needed topics for new and experienced Linux users and programmers - including over 100 utilities and their common ...

    Linux.Essentials.2nd.Edition.111909206X

    An open source operating system, Linux is a UNIX-based platform that is freely updated by developers. The nature of its development means that Linux is a low-cost and secure alternative to other ...

    Windows下Linux常用命令集合

    习惯了在Linux下使用命令的朋友, 现在可以在Windows使用大部分和Linux相同或相似的命令了. 例如grep,du,dd,less等等.只需要在%PATH%里添加路径(UnxUtils\usr\local\wbin),就可以方便地使用Linux常用命令了.

    Embedded Linux Primer.pdf

    Linux Source Organization Section 16.2. Custom Linux for Your Board Section 16.3. Platform Initialization Section 16.4. Putting It All Together Section 16.5. Chapter Summary Chapter 17. Linux and ...

    linux 实用makefile例子

    # Command: # ------基本上简单用法的makefile------- #1. 第一个目标为最终目标 #2. 命令以 Tab开头,可以有多个命令 #3. 分行号\ 后面不可以跟空格 #4、加@可以去掉命令显示 #5. 变量为 abc = efd 访问为 $...

    snixos_1.0_20050802_112713 一个小型的操作系统,采用gcc进行开发,几千行的代码,方便初学者学习

    一个小型的操作系统,采用gcc进行开发,几千行的代码,方便初学者... in Linux : invoke this command: bochs -f ./bochsrc-fd-Lnx.bxrc Enjoy fun! snallie@tom.com, jockeyson@tom.com Tue Aug 2 11:26:43 CST 2005

Global site tag (gtag.js) - Google Analytics