User Tools

Site Tools

tools:bash:shortcuts-piping

This article is Part 2 in a series of cheat-sheets on the command line shell, bash. (Previous Page | Next Page)

bash: Keyboard Shortcuts and Piping Commands

Copy and Paste

  • Ctrl + K (Cut text to end of line)
  • Ctrl + U (Cut text to beginning of line)
  • Ctrl + W (Cut word located behind cursor)
  • Alt + D (Cut word following cursor)
  • Ctrl + Y (Paste most recently cut text)
  • Alt + Y (Rotate back to previously cut text and paste it)

Command Line Editing

  • Up Arrow (Previous Command)
  • Tab (Autocomplete Command)
  • Alt + F (Word Forward)
  • Alt + B (Word Backward)
  • Ctrl + Alt (Beginning of Line)
  • Ctrl + E (End of Line)
  • Ctrl + L (Clear Screen)
  • Alt + T (Transpose Words)
  • Alt + U (Transform Uppercase)
  • Alt + L (Transform Lowercase)
  • Alt + Ctrl (Transform Capitalize)
  • Ctrl + V (Insert Special Character)
  • Ctrl + Ctrl (Delete entire line)

Command Completion

Recall last ten commands from history:

$ history 10

Execute command from history with value of xxx:

$ !xxx

Execute last command from history:

$ !!

Open historical command xxx in text editor:

$ fc xxx

Working With Multiple Commands At Once

Executes pwd followed by ls:

$ pwd ; ls

Executes commands in new child shell:

$ (pwd ; ls)

Sorts passwd and opens the results in less:

$ cat /etc/passwd | sort | less

Untars file in background:

$ tar -xvf file &

Expands variable TEST:

$ echo $TEST

Search for all files in /home containing test in filename and open them in vi:

$ vi $(find /home | grep test)

Example of arithmetic expression:

$ echo "$[2000 - 1500]"

Metacharacters

  • ? (Matches any one character)
  • * (Matches any number of characters)
  • < (Directs contents of file to a command)
  • > (Directs command output to a file)
  • 2> (Directs error from command to a file)
  • &> (Directs command output and errors to a file)
  • » (Directs output to file, appending it to the end of file)
  • | (Pipes output of previous command to input of next command)
  • ; (Sequentially executes next command)
  • & (Runs command in background)
  • $ (For expanding variables, substitutions, and expressions)
  • $( ) (Command substitutions)
  • $[ ] (Arithmetic expressions)


This article is part of a series on Command Line
Linux, MacOS & BSD
Shells: Bash (Getting Started - Shortcuts & Piping - Managing Processes - Users & Permissions - Files & Archives - Customization) - zsh
Emulators/Multiplexers: tmux
Windows
PowerShell

tools/bash/shortcuts-piping.txt · Last modified: 2025/01/04 03:57 by Humphrey Boa-Gart

Find this page online at: https://bestpoint.institute/tools/bash/shortcuts-piping