Home  >  Article  >  Operation and Maintenance  >  What does linux .(dot) mean?

What does linux .(dot) mean?

(*-*)浩
(*-*)浩Original
2019-11-04 09:23:019635browse

What does linux .(dot) mean?

The "." dot command is an internal command of the shell. It reads all command statements from the specified shell file and executes them in the current process. implement. (Recommended learning: linux operation and maintenance)

So when multiple shell processes (either parent-child processes or unrelated processes) share a set of variable values, these variables can be The assignment statement is defined in a shell file, and dot statements are used to reference the shell file in programs that need these variable values, thereby realizing variable value sharing (modifications to these variable values ​​only involve this shell file).

But it should be noted that this shell file cannot include statements containing positional parameters, that is, it cannot accept command line parameters such as $1, $2, etc.

Let’s take this inconspicuous dot (.) as an example. When it is placed at the parameter of a command that requires a directory name, it means "the current directory":

find . -name "*.jpg"

means "Looking for files ending with .jpg in the current directory (including subdirectories) document".

ls . and cd . also work as you would expect, they enumerate and "enter" the current directory respectively, although in both cases this point is redundant.

And two dots, one immediately following the other, in the same scenario (that is, when your command expects a file directory) means "the parent directory of the current directory". If you are currently under /home/your_directory and run:

cd ..

you will enter /home. So, you might think that this still fits the "points represent nearby directories" narrative and is uncomplicated, right?

What will happen next? If you add a dot at the beginning of a file or directory, it means that the file or directory will be hidden:

$ touch somedir/file01.txt somedir/file02.txt somedir/.secretfile.txt
$ ls -l somedir/
total 0
-rw-r--r-- 1 paul paul 0 Jan 13 19:57 file01.txt
-rw-r--r-- 1 paul paul 0 Jan 13 19:57 file02.txt
$ # 注意上面列举的文件中没有 .secretfile.txt
$ ls -la somedir/
total 8
drwxr-xr-x 2 paul paul 4096 Jan 13 19:57 .
drwx------ 48 paul paul 4096 Jan 13 19:57 ..
-rw-r--r-- 1 paul paul 0 Jan 13 19:57 file01.txt
-rw-r--r-- 1 paul paul 0 Jan 13 19:57 file02.txt
-rw-r--r-- 1 paul paul 0 Jan 13 19:57 .secretfile.txt
$ # 这个 -a  选项告诉 ls 去展示“all”文件,包括那些隐藏的

Then you can use . as a command. Yes, listen to me: . is a real command. It's synonymous with the source command, so you can use it to execute a file in the current shell, rather than running a script file in some other way (this usually means Bash will spawn a new shell to run it)

The above is the detailed content of What does linux .(dot) mean?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn