string1-string2 Verified current stable Not installed? Filesystem

String1 String2 / Run Previous Command Substituting String

Run Previous Command Substituting String

Re-runs the last command with substitutions for specific strings.

$
Terminal
^<string1>^<string2>

When To Use

When needing to modify parameters for a command without retyping it entirely.

Pro Tip

Use '!!:s/{{string1}}/{{string2}}/' to replace only the first occurrence in the last command.

Anatomy of Output

Understanding the result

Executing command: ls -l Modified Command

Shows the command that is being executed.

FileName Size Permissions Output Header

Header for the output.

SampleFile.txt 1024 -rw-r--r-- File Details

Indicates details of the specified file.

Troubleshooting

Common pitfalls

zsh: command not found: string1-string2

Solution: Ensure correct syntax: `!!:s/string1/string2`.

zsh: no previous command

Solution: Run a command before substituting strings.

bash: string1: no such file or directory

Solution: Check syntax of the previous command.

Command Breakdown

What each part is doing

^<string1>^<string2>
Base Command
The executable that performs this operation. Here it runs String1 String2 before the shell applies any redirect operators.
<string1>
string1
The value supplied for string1.
<string2>
string2
The value supplied for string2.

Alternative Approaches

Comparable commands in other tools

Alternative filesystem tools for the same job.