The command line
Command line interface
- Windows
- macOS/Linux
- Terminal
We'll be using:
- Windows: Git BASH
- macOS: Terminal
Open it up.
- UNIX
- UNIX-like
- POSIX standard
- Darwin (macOS)
- Debian
- Ubuntu
- Mint
- Fedora
- Red Hat Enterprise Linux (RHEL)
- Separators:
- Windows (outside of Git BASH):
\ - macOS/Linux:
/
- Windows (outside of Git BASH):
.- current directory..- parent directory- Absolute vs. relative
pwd- path of working directoryls- list filesls -al- list all files (with dotfiles) with more details
cd- change directory- Mac:
- From Finder, right-click on folder
- Click
Services - Click
New Terminal at Folder
Control-r allows you to search your command history
- Viewing
catless
mvcpmkdirrmdirfind- Editing
nanovim
If files have spaces or special characters, need to put quotes around them.
- Best to avoid these when naming files, sticking to:
- Letters
- Numbers
- Periods
- Hyphens
- Underscores
- For Python files, snake case is most common.
- less:
q - nano: control-
x - vim: escape, then
:q! - Other command line tools: control-
c
Worst case, close your Terminal, and that will kill whatever process was running.
echoecho abc | less
- Exit codes
echo $?
- Environment variables
whichwhich jupyterwhich -a python3
$PATH- Pipes
ls | xargs cat
- Redirecting output
grepsudoman
Uses a "wildcard":
find . -name 'lecture_*.md'find . -name 'lecture_*.md' | sed -E 's/([0-9]{2})/0\1/'
- PowerShell
- Bash
- zsh
Done through package managers
- conda
- Anaconda channel, maintained by the company
- conda-forge, maintained by the community
- pip
- Virtual environment
- Linux: Aptitude, Snapcraft, others
- Mac: Homebrew
- Windows: Windows Package Manager / WinGet, Chocolatey
Note to self: Send terminal commands+output.