C Shell Wiki
Posts (Latest 10 updated) :
Read all
Contents:
  1. [Linux] C Shell (csh) history 命令: View command history
    1. Overview
    2. Usage
    3. Common Options
    4. Common Examples
    5. Tips

[Linux] C Shell (csh) history 命令: View command history

Overview

The history command in C Shell (csh) is used to display a list of previously executed commands in the current shell session. This allows users to easily recall and reuse commands without having to retype them.

Usage

The basic syntax of the history command is as follows:

history [options] [arguments]

Common Options

  • -c: Clear the history list.
  • -n: Read the history from the history file and append it to the current history list.
  • -r: Read the history from the history file and replace the current history list.
  • -w: Write the current history list to the history file.

Common Examples

  1. Display the command history:
    history
    
  2. Clear the command history:
    history -c
    
  3. Read history from the history file:
    history -r
    
  4. Write the current history to the history file:
    history -w
    
  5. Display the last 10 commands:
    history 10
    

Tips

  • Use !n to execute the command at position n in the history list.
  • To quickly repeat the last command, simply type !!.
  • Consider using history -w regularly to save your command history, especially before closing the terminal.