Showing posts with label cmd. Show all posts
Showing posts with label cmd. Show all posts

# Keyboard shortcuts


bash

ctrl+p: History: previous command (arrow_up).
ctrl+n: History: next command (arrow_down).
ctrl+d: Signal end-of-file (EOF). Close the window, exit program.
ctrl+c: Abort current command/typing.
ctrl+w: Erase word to the left.
alt+d: Erase word to the right.
ctrl+u: Erase line to the left.
ctrl+k: Erase line to the right.
ctrl+y: Yank/Paste previously erased string.
alt+b: Move one word to the left.
alt+f: Move one word to the right.
ctrl+a: Move to beginning of line.
ctrl+e: Move to end of line.
ctrl+r: History: reverse search.
ctrl+z: Stop execution of the current job.
tab: Autocomplete command/file name.
shift+ins: Paste contents of clipboard at cursor.
shift+page_up: Scroll window up.
shift+page_down: Scroll window down.

cmd

arrow_up: History: previous command.
arrow_down: History: next command.
ctrl+c: Abort current command/typing.
ctrl+home: Erase line to the left.
ctrl+end: Erase line to the right.
ctrl+arrow_left: Move one word to the left.
ctrl+arrow_right: Move one word to the right.
home: Move to beginning of line.
end: Move to end of line.
F8: History: reverse search.
tab: Autocomplete file name.


vim

x: Delete char to the right of cursor.
dw: Delete word to the right of cursor.
db: Delete word to the left of cursor.
0: Go to start of line.
$: Go to end of line.
1G: Go to start of document.
$G: Go to end of document.
b: Go to previous word.
w: Go to next word.
k: Go to previous line (arrow-up).
j: Go to next line (arrow-down).
{: Go to previous paragraph.
}: Go to next paragraph.
/: Search.
N: Go to previous search result.
n: Go to next search result.
:%s/yin/yang/g: Search and replace.

# Windows command line

Help
C:\>help dir
C:\>dir /?
Echo
C:\>echo on
C:\>echo off
C:\>echo Test
C:\>echo.
C:\>@help rem
Regular expressions
C:\>dir *.txt
C:\>dir ???.txt
Redirections
C:\>echo x > file01.txt
C:\>pause < file01.txt
C:\>type file02.txt 2> error.txt
C:\>type file03.txt > output_error.txt 2>&1
Filters
C:\>echo x | pause
C:\>dir | more
C:\>dir | sort | more
C:\>findstr "good night" file04.txt
Environment variables
C:\>set | more
C:\>set var1=1
C:\>ser var2=2
C:\>set var
C:\>set var1=
C:\>set var2=
C:\>set path=%path%;dir01
C:\>echo %computername%
C:\>echo %date%
C:\>echo %time%
C:\>echo %errorlevel%
C:\>echo %number_of_processors%
C:\>echo %os%
C:\>echo %path%
C:\>echo %pathext%
C:\>echo %processor_architecture%
C:\>echo %processor_identifier%
C:\>echo %processor_level%
C:\>echo %processor_revision%
C:\>echo %random%
Copy files
C:\>rem Copy files and directories recursively
C:\>xcopy /?
Compare files
C:\>rem Compare
C:\>comp file1 file2
C:\>rem Compare
C:\>fc file1 file2
Adjusting de cmd
C:\>rem Size
C:\>mode 120x120
C:\>rem Color [0xbackground, 0xforeground]
C:\>color 0a
C:\>rem Window title
C:\>title Network info
Directory listing
C:\>tree /a /f C:\
Scripts
C:\>type script.cmd
@echo off
rem script.cmd
cls
echo.
echo Script name: %0
echo First parameter: %1
echo Second parameter: %2
for %%i in (*.txt) do type %%i
C:\>script p1 p2
Escape
C:\>echo a is ^> than b
Flux control
C:\>call script.cmd %1 %2
C:\>cmd /k dir
C:\>start dir
C:\>for %i in (*.txt) do type %i
C:\>for /D /r %i in (*) do @echo dir: %i
C:\>for /R %i in (*.bak) do del %i
C:\>for /L %i in (1,1,10) do @echo %i
C:\>echo "a 1" >> file05.txt
C:\>echo "b 2" >> file05.txt
C:\>echo "c 3" >> file05.txt
C:\>for /F "tokens=1,2" %i in (file05.txt) do @echo t2=%j t1=%i
C:\>for /F "delims=: tokens=1-2 usebackq" %i in (`time /t`) do @echo %i:%j
C:\>type file06.txt
@echo off
goto message2
echo message1
:message2
echo message2
C:\>if not exist file07.txt echo "No file"
C:\>exit /b 0