Terminal and shell

Save terminal output to a file

Send a command's output into a file instead of (or as well as) the screen.

Fill these in once
  1. Save the output to a file
    Terminal
    ls -la > output.txt

    This replaces the file each time.

  2. Add to the end of the file instead
    Terminal
    ls -la >> output.txt
  3. Save errors too
    Terminal
    ls -la > output.txt 2>&1
  4. See it on screen and save it at the same time
    Terminal
    ls -la | tee output.txt
  1. Save the output to a file
    Terminal · Ubuntu / Debian
    ls -la > output.txt

    This replaces the file each time.

  2. Add to the end of the file instead
    Terminal · Ubuntu / Debian
    ls -la >> output.txt
  3. Save errors too
    Terminal · Ubuntu / Debian
    ls -la > output.txt 2>&1
  4. See it on screen and save it at the same time
    Terminal · Ubuntu / Debian
    ls -la | tee output.txt
  1. Save the output to a file
    PowerShell
    Get-ChildItem | Out-File output.txt

    This replaces the file each time.

  2. Add to the end of the file instead
    PowerShell
    Get-ChildItem | Out-File output.txt -Append
  3. Save errors too
    PowerShell
    Get-ChildItem *> output.txt
  4. See it on screen and save it at the same time
    PowerShell
    Get-ChildItem | Tee-Object output.txt