ArticleslgStudy

computer science

History (command)

History (command) is a computer 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 History (command) rather than just read about it. In short: In computing, various shells maintain a record of the commands issued by the user during the current session. The history command works with the command history list.

Key takeaways

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

Reference excerpt

In computing, various shells maintain a record of the commands issued by the user during the current session. The history command works with the command history list. When the command is issued with no options, it prints the history list. Users can supply options and arguments to the command to manipulate the display of the history list and its entries. The operation of the history command can also be influenced by a shell's environment variables. For example, an environment variable can be set to control the number of commands to retain in the list.

History In early versions of Unix the history command was a separate program. However, most shells have long included the history command as a shell built-in, so the separate program is no longer in common use.

Implementations The command is available in various Unix shells, as well as in PowerShell, ReactOS, and KolibriOS. It is also included as external command in PTS-DOS where it keeps a resident part, sometimes in conventional memory. Since most current history commands are shell built-ins, details depend on the choice of shell.

bash The history command has the following syntax in bash:

history [-c] [-d offset] [n] history -awrn [filename] history -ps arg [arg...]

tcsh The history command has the following syntax in tcsh:

history [-hTr] [n] history -S|-L|-M [filename] (+) history -c (+)

The first form prints the history event list. If n is given only the n most recent events are printed or saved. With -h, the history list is printed without leading numbers. If -T is specified, timestamps are printed also in comment form. (This can be used to produce files suitable for loading with 'history -L' or 'source -h'.) With -r, the order of printing is most recent first rather than oldest first. With -S, the second form saves the history list to filename. If the first word of the savehist shell variable is set to a number, at most that many lines are saved. If the second word of savehist is set to `merge', the history list is merged with the existing history file instead of replacing it (if there is one) and sorted by time stamp. (+) Merging is intended for an environment like the X Window System with several shells in simultaneous use. Currently it succeeds only when the shells quit nicely one after another. With -L, the shell appends filename, which is presumably a history list saved by the -S option or the savehist mechanism, to the history list. -M is like -L, but the contents of filename are merged into the history list and sorted by timestamp. In either case, histfile is used if filename is not given and ~/.history is used if histfile is unset. `history -L' is exactly like 'source -h' except that it does not require a filename. Note that login shells do the equivalent of `history -L' on startup and, if savehist is set, `history -S' before exiting. Because only ~/.tcshrc is normally sourced before ~/.history, histfile should be set in ~/.tcshrc rather than ~/.login. If histlit is set, the first and second forms print and save the literal (unexpanded) form of the history list. The last form clears the history list.

PowerShell In PowerShell, history is a predefined command alias for the Get-History cmdlet. In addition, PowerShell includes the Add-History, Clear-History, Get-History, and Invoke-History cmdlets. The *-History cmdlets serve the same purpose as the Unix-like history command.

Get-History [[-Id] <Int64[]>] [[-Count] <Int32>] [<CommonParameters>] Add-History [[-InputObject] <PSObject[]>] [-Passthru] [<CommonParameters>] Clear-History [[-Id] <Int32[]>] [[-Count] <Int32>] [-Newest] [-Confirm] [-WhatIf] [<CommonParameters>] Clear-History [[-Count] <Int32>] [-CommandLine <String[]>] [-Newest] [-Confirm] [-WhatIf] [<CommonParameters>] Invoke-History [[-Id] <String>] [-Confirm] [-WhatIf] [<CommonParameters>]

ReactOS Command Prompt The history command of the ReactOS Command Prompt currently only supports printing the history list.

See also List of command-line interpreters

References

Further reading McElhearn, Kirk (2006). The Mac OS X Command Line: Unix Under the Hood. John Wiley & Sons. ISBN 978-0470113851.

Worked examples

Example 1 — a first encounter with History (command)

Start with the simplest possible case. Write down what History (command) claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer 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 History (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 History (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 History (command)

In research
History (command) appears in computer 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 History (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
History (command) is common in secondary-school and first-year university syllabi. It links to neighbouring topics ReactOS commands, Unix software, Windows administration, so understanding it makes those chapters shorter.
In everyday life
Look for History (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.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “History (command)” →

How to study History (command) in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what History (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 History (command) out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is History (command) in simple terms?

In computing, various shells maintain a record of the commands issued by the user during the current session. The history command works with the command history list.

Why does History (command) matter?

Because it connects several computer 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 History (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 History (command).

Tags

  • ReactOS commands
  • Unix software
  • Windows administration

Keep exploring