LinuxCommandLibrary

r

Repeat the last command

TLDR

Start a REPL (interactive shell)

$ R
copy

Start R in vanilla mode (i.e. a blank session that doesn't save the workspace at the end)
$ R [[-v|--vanilla]]
copy

Execute a file
$ R [[-f|--file]] [path/to/file.R]
copy

Execute an R expression and then exit
$ R -e [expr]
copy

Run R with a debugger
$ R [[-d|--debugger]] [debugger]
copy

Check R packages from package sources
$ R CMD check [path/to/package_source]
copy

Display version
$ R --version
copy

SYNOPSIS

r [no options/arguments typically for a simple alias]
(commonly aliased to `fc -s` or `!!`)

PARAMETERS

No direct parameters for the alias 'r'
    When 'r' is used as a simple alias, it typically doesn't accept direct parameters. Its functionality is pre-defined by the alias itself.


    Executes the command corresponding to the specified history event number. This is a common pattern for what 'r' might be aliased to (e.g., alias r='fc -s' or alias r='!!', but also custom aliases like alias r10='!10').

-
    Executes the command found by counting commands back from the current line. For example, !-1 is equivalent to !!.

!
    Executes the most recent command in history that begins with . This is often used for quick re-execution (e.g., !ls to re-run the last ls command).

!!
    Executes the immediately preceding command. This is one of the most common actions 'r' is aliased to (e.g., alias r='!!').

DESCRIPTION

The letter "r" is not a standard, standalone Linux command or executable. Instead, it is very commonly used as a custom
shell alias or function by users to quickly repeat previous commands from their command history.

Typically, when a user types "r", it's configured to execute one of the following underlying shell features:

  • fc -s: A shell built-in (from Korn shell, adopted by Bash) that re-executes the last command from the history list.
  • !!: A shell history expansion (from C shell, adopted by Bash, Zsh) that re-executes the immediately preceding command.
  • !: Re-executes the command corresponding to a specific history event number.
  • !: Re-executes the most recent command starting with the specified string.

The exact behavior of "r" is entirely dependent on the user's shell configuration files (e.g., .bashrc, .zshrc), where the alias or function is defined.

CAVEATS

  • Not a Standard Executable: "r" is not a standard Linux command found in /bin, /usr/bin, or other common executable paths by default. It's almost always a user-defined shortcut.
  • Shell-Dependent: Its existence and behavior are entirely dependent on the user's shell configuration (e.g., Bash, Zsh, Fish) and whether they have explicitly defined it.
  • Potential Conflicts: On systems where the R statistical programming language is installed, the executable for R is often named R (capitalized), but a user alias of r (lowercase) could potentially conflict or cause confusion if not carefully managed.
  • No Manual Page: Because it's not a standard command, there is no dedicated man r page.

R STATISTICAL LANGUAGE

The letter "R" (capitalized) can also refer to the R programming language, a free software environment for statistical computing and graphics. When installed on Linux, its executable is typically named R. This is distinct from any shell alias "r" used for command history recall.

HISTORY

The ability to recall and re-execute commands from shell history is a fundamental feature of modern Unix-like shells, dating back to early shells like the C shell (csh) in the late 1970s, which introduced the '!' history expansion mechanism. The fc (fix command) built-in originated in the Korn shell (ksh) in the early 1980s and was later adopted by Bash. The use of "r" as a simple alias for these powerful history features is a widespread user convenience, demonstrating the flexibility and customizability of Unix shells rather than being a specific historical development of an 'r' command itself.

SEE ALSO

history(1), fc(1), bash(1), zsh(1), sh(1)

Copied to clipboard