Commandline¶
Shape (1)¶
Consists of three parts … well mostly, this is just convention.
Command: executable program, or script, shell alias (see below), or shell builtin (like
cd
)Options: e.g.
-i
(short option), oder--interactive
(long option)Arguments: file names, mostly
Shape (2)¶
$ cp -i -r /etc ~/tmp
$ cp -ir /etc ~/tmp
Command:
cp
Options:
-i
and-r
Arguments:
/etc
and/tmp
Options¶
Alternative: long options; e.g.
cp
--interactive
instead of-i
--recursive
instead of-r
⟶ shell scripts
⟶ readability
“Standard” options
-h
or--help
: brief overview-v
or--verbose
: log/debug outout as the command runs--version
: command version
There is no standard, only evolution
$ dd if=/dev/zero of=/dev/null count=20 bs=1024
$ ls -h Documents Downloads Pictures
Help and Manual¶
Command explains itself when given the option
--help
(well, mostly)$ find --help Usage: find [-H] [-L] [-P] [-Olevel] [-D debugopts] [path...] [expression] default path is the current directory; default expression is -print expression may consist of: operators, options, tests, and actions: operators (decreasing precedence; -and is implicit where no others are given): ( EXPR ) ! EXPR -not EXPR EXPR1 -a EXPR2 EXPR1 -and EXPR2 EXPR1 -o EXPR2 EXPR1 -or EXPR2 EXPR1 , EXPR2 positional options (always true): -daystart -follow -regextype ...
Complete Description is in the manual page (or man page, for short)
$ man find
FIND(1) General Commands Manual FIND(1) NAME find - search for files in a directory hierarchy SYNOPSIS find [-H] [-L] [-P] [-D debugopts] [-Olevel] [starting-point...] [expression] DESCRIPTION This manual page documents the GNU version of find. GNU find searches the directory tree rooted at each given starting-point by evaluating the given expression from left to right, according to the rules of precedence (see section OPERATORS), until the outcome is known (the left hand side is false for and operations, true for or), at which point find moves on to the next file name. If no starting-point is specified, `.' is assumed. If you are using find in an environment where security is important (for example if you are using it to search directories that are writable by other users), you should read the `Security Considerations' chapter of the findu‐ tils documentation, which is called Finding Files and comes with findutils. That document also includes a lot more detail and discussion than this manual page, so you may find it a more useful source of information. OPTIONS The -H, -L and -P options control the treatment of symbolic links. Command-line arguments following these are taken to be names of files or directories to be examined, up to the first argument that begins with `-', or the argument `(' or `!'. That argument and any following arguments are taken to be the expression describing what is to be searched for. If no paths are given, the current directory is used. If no expression is given, the ex‐ pression -print is used (but you should probably consider using -print0 instead, anyway). ... 20 kilometers more ...
Commandline Editing: Moving, Deleting¶
Noob: run away screaming!!
Expert: come on, don’t panic!
Keystroke |
Description |
---|---|
← |
One character left |
→ |
One character right |
|
Delete character left of cursor |
|
Delete character below cursor |
|
Move cursor to beginning of line |
|
Move cursor to end of line |
C-k |
Delete character below cursor, until end of line |
C-u |
Delete character left of cursor, until beginning of line |
C-l (“ell”) |
Clear screen |
Commandline Editing: Entire Words¶
Keystroke |
Description |
---|---|
C-<left>, M-b |
Move cursor one word left |
C-<right>, M-f |
Move cursor one word right |
M-d |
Delete word right |
M-<backspace> |
Delete word left |
Note
Arrow keys don’t always work (embedded systems are often misconfigured in this regard) ⟶ best to get used to real keys
Should the
M
(Meta,Alt
) not work, one can useESC
, followed by the combined character.For example
Alt+d
(pressed at the same time) is the same asESC
, followed byd
Commandline Editing: Entire Lines¶
Note
Keys for freaks, nerds, and Emacs addicts.
Keystroke |
Description |
---|---|
C-y, M-y |
Insert from kill ring (here) |
C-_ |
Undo |
C-t |
Transpose characters |
M-t |
Transpose words |
M-u |
Uppercase word |
M-l |
Lowercase word |
M-c |
Capitalize word |
The Tabulator Key: Command Completion¶
Usage absolutely recommended
Nobody remembers, for example, all commands the start with
git
$ git # <-- HIT <TAB> HERE AFTER 'git' git git-p4 git-resurrect git-upload-archive gitk git-cvsserver git-receive-pack git-shell git-upload-pack gitview
The Tabulator Key: Filename Completion¶
Usage absolutely recommended
Nobody wants to type long paths
Single
TAB
completes until ambiguityDouble
TAB
shows alternatives
$ less ~/Doc # <-- HIT <TAB> HERE -> COMPLETES
$ less ~/Documents/ # <-- HIT <TAB> HERE TWICE -> ALTERNATIVES
2021-12-26-Oesterreich-Pre-Travel-Clearance.pdf e7d76d19-dd3d-4d52-9394-2c16dc73f9d1_VStV_921302213705_2021___VStVF.pdf python-3.10.0-docs-html/
boardingpass_1d9xf3dvd1uzt00tsswu68duh.gif Einkommensteuerbescheid1.pdf python-doc.zip
boardingpass_b6uy9xqgeojspx1hxshogcbbq.gif Einkommensteuervorauszahlungsbescheid1.pdf RF-Immobilienbewertung-ETW-2022.pdf
Booking.com Confirmation.pdf Fedora 34 ECE 19.ova Umsatzsteuerbescheid1.pdf
Buchhaltung.csv H0020211105124337.pdf VK9VST311192021_0022021.pdf
$ less ~/Documents/Bu # <-- HIT <TAB> -> COMPLETES
less ~/Documents/Buchhaltung.csv
... shows boring stuff ...