ArticleslgStudy

science

Dot (command)

Dot (command) is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Dot (command) rather than just read about it. In short: In a Unix shell, the full stop called the dot command (.) is a command that evaluates commands in a computer file in the current execution context. In the C shell, a similar functionality is provided as the source command, and this name is seen in "extended" POSIX shells as well.

Key takeaways

  • Dot (command) belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Dot (command) to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Dot (command) from memory before moving on to harder problems.

Reference excerpt

In a Unix shell, the full stop called the dot command (.) is a command that evaluates commands in a computer file in the current execution context. In the C shell, a similar functionality is provided as the source command, and this name is seen in "extended" POSIX shells as well. The dot command is not to be confused with a dot file, which is a dot-prefixed hidden file or hidden directory. Nor is it to be confused with the ./scriptfile notation for running commands, which is simply a relative path pointing to the current directory (notated in Unix as a '.' character, and typically outside of the Path variable).

Arguments The filename is the dot command's first argument. When this argument does not contain a slash, the shell will search for the file in all directories defined in the PATH environment variable. Unlike normal commands which are also found in PATH, the file to source does not have to be executable. Otherwise the filename is considered as a simple path to the file. In several "extended" shells including bash, zsh and ksh, one may specify parameters in a second argument. If no parameters are specified, the sourced file will receive the set of positional parameters available in the current context. If parameters are specified, the sourced file will receive only the specified parameters. In any case, parameter $0 will be the $0 of the current context.

Usages Since the execution of the source file is done in the invoking context, environment, changes within apply to the current process or shell. This is very different from scripts run directly by shebang or as sh foo.sh, which are run in a new, separate process space, with a separate environment. Therefore, the dot command can be used for splitting a big script into smaller pieces, potentially enabling modular design. Sourcing is also often done by the shell on session startup for user profile files like .bashrc and .profile.

source source is a shell-builtin command that evaluates the file following the command, as a list of commands, executed in the current context. Frequently the "current context" is a terminal window into which the user is typing commands during an interactive session. The source command can be abbreviated as just a dot (.) in Bash and similar POSIX-ish shells. However, this is not acceptable in C shell, where the command first appeared. Some Bash scripts should be run using the source your-script syntax rather than run as an executable command, e.g., if they contain a change directory (cd) command and the user intends that they be left in that directory after the script is complete, or they contain an export command and the user wants to modify the environment of the current shell. Another usage situation is when a script file does not have the "execute" permission. Passing the script filename to the desired shell will run the script in a subshell, not the current context.

Notes

References

External links The three different uses of the dot in Unix explained

Worked examples

Example 1 — a first encounter with Dot (command)

Start with the simplest possible case. Write down what Dot (command) claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Dot (command) before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Dot (command) ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Dot (command)

In research
Dot (command) appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Dot (command) in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Dot (command) is common in secondary-school and first-year university syllabi. It links to neighbouring topics IBM i Qshell commands, Standard Unix programs, Unix SUS2008 utilities, so understanding it makes those chapters shorter.
In everyday life
Look for Dot (command) outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Dot (command) in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Dot (command) means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Dot (command) out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Dot (command) in simple terms?

In a Unix shell, the full stop called the dot command (.) is a command that evaluates commands in a computer file in the current execution context. In the C shell, a similar functionality is provided as the source command, and this name is seen in "extended" POSIX shells as well.

Why does Dot (command) matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Dot (command)?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Dot (command).

Tags

  • IBM i Qshell commands
  • Standard Unix programs
  • Unix SUS2008 utilities

Keep exploring