\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{rebecca-burwei} \pdfinfo{ /Title (beginner-bash.pdf) /Creator (Cheatography) /Author (rebecca-burwei) /Subject (Beginner Bash Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{141414} \definecolor{LightBackground}{HTML}{F7F7F7} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Beginner Bash Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{rebecca-burwei} via \textcolor{DarkBackground}{\uline{cheatography.com/121026/cs/21996/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}rebecca-burwei \\ \uline{cheatography.com/rebecca-burwei} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 31st March, 2020.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{2} \begin{tabularx}{8.4cm}{x{3.28 cm} x{4.72 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Builtin commands}} \tn % Row 0 \SetRowColor{LightBackground} builtin & Uses builtin version of the command \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} cut -f{\emph{number}} -d{\emph{delimiter}} & Displays the column specified by number \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} disown & Removes processes from the shell's list of jobs. Removes the job id. \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} eval & Re-run CL processing on arguments. Can be used to run commands passed as variables. \tn % Row Count 11 (+ 4) % Row 4 \SetRowColor{LightBackground} fg \%{\emph{N}} & Bring the job with shell ID {\emph{N}} to the foreground \tn % Row Count 14 (+ 3) % Row 5 \SetRowColor{white} getopts & Parses positional parameters \tn % Row Count 16 (+ 2) % Row 6 \SetRowColor{LightBackground} grep -e & Regex searches for a pattern in lines in the argument files, or stdin if no files \tn % Row Count 20 (+ 4) % Row 7 \SetRowColor{white} jobs & List all jobs \tn % Row Count 21 (+ 1) % Row 8 \SetRowColor{LightBackground} printf & Prints a format string \tn % Row Count 22 (+ 1) % Row 9 \SetRowColor{white} read & Reads a line from stdin, spits it on `\$IFS` characters, and assigns it to shell variables \tn % Row Count 26 (+ 4) % Row 10 \SetRowColor{LightBackground} trap & When specified signals are received, run specified command instead and resume normal execution \tn % Row Count 31 (+ 5) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{3.28 cm} x{4.72 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Builtin commands (cont)}} \tn % Row 11 \SetRowColor{LightBackground} type & Displays paths of argument commands, aliases, functions, executables \tn % Row Count 3 (+ 3) % Row 12 \SetRowColor{white} wait & Waits for all background jobs to finish before finishing the script. \tn % Row Count 6 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.36 cm} x{6.64 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Emacs commands}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{CTRL-A} & Move to beginning of line \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \seqsplit{CTRL-E} & Move to end of line \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \seqsplit{CTRL-U} & Kill backward to beginning of line \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} \seqsplit{CTRL-K} & Kill forward to end of line \tn % Row Count 5 (+ 1) % Row 4 \SetRowColor{LightBackground} \seqsplit{CTRL-R} & Search backward \tn % Row Count 6 (+ 1) % Row 5 \SetRowColor{white} \seqsplit{CTRL-Y} & Retrieve (yank) last killed item \tn % Row Count 7 (+ 1) % Row 6 \SetRowColor{LightBackground} ESC-B & Move one word backward \tn % Row Count 8 (+ 1) % Row 7 \SetRowColor{white} ESC-F & Move one word forward \tn % Row Count 9 (+ 1) % Row 8 \SetRowColor{LightBackground} \seqsplit{ESC-DEL} & Kill one word backward \tn % Row Count 11 (+ 2) % Row 9 \SetRowColor{white} ESC-D & Kill one word forward \tn % Row Count 12 (+ 1) % Row 10 \SetRowColor{LightBackground} ESC-\textless{} & Move to first line of history list \tn % Row Count 14 (+ 2) % Row 11 \SetRowColor{white} ESC-\textgreater{} & Move to last line of history list \tn % Row Count 15 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Environment files}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{.bash\_profile - Runs when a login shell starts.} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{.bashrc - Runs when a subshell starts.} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{.bash\_logout - Runs when a login shell exits.} \tn % Row Count 3 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{p{0.88 cm} x{7.12 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Special Characters}} \tn % Row 0 \SetRowColor{LightBackground} \& & Background job \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \# & Comment \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \textasciitilde{} & Home directory \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} ! & Logical NOT \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} ' & Quote (strong). Skips all CL processing. \tn % Row Count 6 (+ 2) % Row 5 \SetRowColor{white} " & Quote (weak). Skips all CL processing except variable expansion, command substitution, arithmetic substitution. \tn % Row Count 10 (+ 4) % Row 6 \SetRowColor{LightBackground} \textless{} & Redirect input \tn % Row Count 11 (+ 1) % Row 7 \SetRowColor{white} \textgreater{} & Redirect output \tn % Row Count 12 (+ 1) % Row 8 \SetRowColor{LightBackground} \textgreater{}\textgreater{} & Redirect output and append to file \tn % Row Count 13 (+ 1) % Row 9 \SetRowColor{white} | & Redirect (pipe) output to next command \tn % Row Count 15 (+ 2) % Row 10 \SetRowColor{LightBackground} / & Separator for pathname directories \tn % Row Count 16 (+ 1) % Row 11 \SetRowColor{white} ; & Separator for shell commands. Use when EOL is missing. \tn % Row Count 18 (+ 2) % Row 12 \SetRowColor{LightBackground} {[} {]} & Start and end a character-set wildcard \tn % Row Count 20 (+ 2) % Row 13 \SetRowColor{white} \{ \} & Start and end a command block. Redirect I/O to a block of commands without starting a subprocess. \tn % Row Count 23 (+ 3) % Row 14 \SetRowColor{LightBackground} ( ) & Start and end a subshell \tn % Row Count 24 (+ 1) % Row 15 \SetRowColor{white} (( )) & Perform arithmetic \tn % Row Count 26 (+ 2) % Row 16 \SetRowColor{LightBackground} * & Wildcard \tn % Row Count 27 (+ 1) % Row 17 \SetRowColor{white} ? & Wildcard - single character \tn % Row Count 28 (+ 1) % Row 18 \SetRowColor{LightBackground} \$ & Variable expression \tn % Row Count 29 (+ 1) % Row 19 \SetRowColor{white} \textbackslash{} & Escape a special character (including RETURN) \tn % Row Count 31 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.36 cm} x{6.64 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{More I/O Redirectors}} \tn % Row 0 \SetRowColor{LightBackground} {\emph{n}}\textgreater{}\&{\emph{m}} & File descriptor {\emph{n}} is made to be a copy of output file descriptor {\emph{m}} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} {\emph{n}}\textless{}\&{\emph{m}} & File descriptor {\emph{n}} is made to be a copy of input file descriptor {\emph{m}} \tn % Row Count 6 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.36 cm} x{6.64 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{read builtin}} \tn % Row 0 \SetRowColor{LightBackground} `-a` & Read values into an array \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} `-d{\emph{D}}` & Only read lines up to the character {\emph{D}} \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} `-n` {\emph{N}} & Only read the first {\emph{N}} characters of each line \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} `-p` & Prints the string before reading input \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} `-r` & Usually backslash indicates a line continuation. This option interprets escaped characters like `\textbackslash{}n` \tn % Row Count 11 (+ 4) % Row 5 \SetRowColor{white} `-s` & Do not echo the characters typed into the terminal \tn % Row Count 13 (+ 2) % Row 6 \SetRowColor{LightBackground} `-t` {\emph{T}} & Wait {\emph{T}} seconds for input, then finish \tn % Row Count 15 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{p{2 cm} x{6 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Signals}} \tn % Row 0 \SetRowColor{LightBackground} INT & Ctrl-C \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} TSTP & Ctrl-Z \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} TERM & `kill` \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} QUIT & `kill -QUIT` \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} KILL & `kill -KILL` \tn % Row Count 5 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.48 cm} x{5.52 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Variables}} \tn % Row 0 \SetRowColor{LightBackground} \$0, \$1, \$2, ... & Positional parameters \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \$@ & "\$1" "\$2" "\$3" ... \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} \$* & A string of positional params \textgreater{} 0 \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} \$\# & Number of positional params - 1 \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} \$? & Exit status of last command run \tn % Row Count 9 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.56 cm} x{5.44 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Run a script}} \tn % Row 0 \SetRowColor{LightBackground} `source {\emph{myscript}}` & Run in current shell \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `./{\emph{myscript}}` & Run script in a subshell \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} `{\emph{myscript}}` & Run script in subshell. Must be in `\$PATH` \tn % Row Count 6 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Functions}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{Two ways to define: \newline % Row Count 1 (+ 1) `function {\emph{myfunction}} \{ ... \}` \newline % Row Count 2 (+ 1) `{\emph{myfunction}} ( ) \{ ... \}` \newline % Row Count 3 (+ 1) Call a function: \newline % Row Count 4 (+ 1) `{\emph{myfunction}} arg1 arg2` \newline % Row Count 5 (+ 1) Keywords: \newline % Row Count 6 (+ 1) `local` - Limit variable scope. `\$@, \$*, \$\#, \$0, \$1` are automatically local.% Row Count 8 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.52 cm} x{4.48 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{String operators}} \tn % Row 0 \SetRowColor{LightBackground} `\$\{{\emph{varname}}:-{\emph{word}}\}` & Returns {\emph{word}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `\$\{{\emph{varname}}:={\emph{word}}\}` & Sets and returns {\emph{word}} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} `\$\{{\emph{varname}}:?{\emph{message}}\}` & Prints {\emph{message}} and exits \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} `\$\{{\emph{varname}}:{\emph{offset}}:{\emph{length}}\}` & Returns substring (1-indexed) \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} `\$\{{\emph{varname}}:+{\emph{word}}\}` & If {\emph{varname}} is defined, then returns {\emph{word}}. Else returns null. \tn % Row Count 11 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{If {\emph{varname}} does not exist or is null, then string operators follow the behavior above (except for the `:+`).} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.76 cm} x{4.24 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Pattern-matching operators}} \tn % Row 0 \SetRowColor{LightBackground} `\$\{{\emph{varname}}\#{\emph{pattern}}\}` & Match shortest from the start and delete \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `\$\{{\emph{varname}}\#\#{\emph{pattern}}\}` & Match longest from the start and delete \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} `\$\{{\emph{varname}}\%{\emph{pattern}}\}` & Match shortest from the end and delete \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} `\$\{{\emph{varname}}\%\%{\emph{pattern}}\}` & Match longest from the end and delete \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} `\$\{{\emph{varname}}/{\emph{pattern}}/{\emph{replace}}\}` & Match longest and replace \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} `\$\{{\emph{varname}}//{\emph{pattern}}/{\emph{replace}}\}` & Match all and replace \tn % Row Count 12 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{If / else conditions}} \tn % Row 0 \SetRowColor{LightBackground} {\emph{statement1}} `\&\&` {\emph{statement2}} & If {\emph{statement1}} runs, then run {\emph{statement2}} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} {\emph{statement1}} `||` {\emph{statement2}} & If {\emph{statement1}} fails, then run {\emph{statement2}} \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} {\emph{statement1}} `-a` {\emph{statement2}} & {\emph{statement1}} AND {\emph{statement2}} \tn % Row Count 8 (+ 2) % Row 3 \SetRowColor{white} {\emph{statement1}} `-o` {\emph{statement2}} & {\emph{statement1}} OR {\emph{statement2}} \tn % Row Count 10 (+ 2) % Row 4 \SetRowColor{LightBackground} `-lt`, `-le`, `-eq`, `-gt`, `-ge`, `-ne` & Integer comparisons \tn % Row Count 12 (+ 2) % Row 5 \SetRowColor{white} `=`, `!=`, `\textless{}`, `\textgreater{}` & String comparisons \tn % Row Count 13 (+ 1) % Row 6 \SetRowColor{LightBackground} `-n {\emph{str1}}` & {\emph{str1}} has length \textgreater{} 0 \tn % Row Count 15 (+ 2) % Row 7 \SetRowColor{white} `-z {\emph{str1}}` & {\emph{str1}} has length 0 \tn % Row Count 16 (+ 1) % Row 8 \SetRowColor{LightBackground} `-d {\emph{file}}` & {\emph{file}} exists and is a directory \tn % Row Count 18 (+ 2) % Row 9 \SetRowColor{white} `-e {\emph{file}}` & {\emph{file}} exists \tn % Row Count 19 (+ 1) % Row 10 \SetRowColor{LightBackground} `-f {\emph{file}}` & {\emph{file}} exists and is a regular file \tn % Row Count 21 (+ 2) % Row 11 \SetRowColor{white} `-r {\emph{file}}` & User has read permission on {\emph{file}} \tn % Row Count 23 (+ 2) % Row 12 \SetRowColor{LightBackground} `-s {\emph{file}}` & {\emph{file}} exists and is not empty \tn % Row Count 25 (+ 2) % Row 13 \SetRowColor{white} `-w {\emph{file}}` & User has write permission on {\emph{file}} \tn % Row Count 27 (+ 2) % Row 14 \SetRowColor{LightBackground} `-x {\emph{file}}` & User has execute permission on {\emph{file}}, or search permission if it's a directory \tn % Row Count 31 (+ 4) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{If / else conditions (cont)}} \tn % Row 15 \SetRowColor{LightBackground} `-N {\emph{file}}` & {\emph{file}} was modified since it was last read \tn % Row Count 3 (+ 3) % Row 16 \SetRowColor{white} `-O {\emph{file}}` & User owns {\emph{file}} \tn % Row Count 4 (+ 1) % Row 17 \SetRowColor{LightBackground} `-G {\emph{file}}` & {\emph{file}}'s group ID matches one of the user's group IDs \tn % Row Count 7 (+ 3) % Row 18 \SetRowColor{white} {\emph{file1}} `-nt` {\emph{file2}} & {\emph{file1}} has a newer modification time than {\emph{file2}} \tn % Row Count 10 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{All of the above conditions must go in square brackets (`{[} {]}`) because if/else test against {\emph{exit codes}}. Parentheses indicting order of operations within square brackets must be escaped with a backslash.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Other flow control}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{`for` - Defaults to looping through `\$@`. Set loop delimiter using `\$IFS`. \newline % Row Count 2 (+ 2) `case` {\emph{expression}} `in` \newline % Row Count 3 (+ 1) ~~~~{\emph{pattern1}} `)` \newline % Row Count 4 (+ 1) ~~~~~~~~{\emph{statements}} `;;` \newline % Row Count 6 (+ 2) ~~~~{\emph{pattern2}} `|` {\emph{pattern3}} `)` \newline % Row Count 8 (+ 2) ~~~~~~~~{\emph{statements}} `;;` \newline % Row Count 10 (+ 2) ~~~~... \newline % Row Count 11 (+ 1) ~~~~`* )` \newline % Row Count 12 (+ 1) ~~~~~~~~{\emph{last statements}} `;;` \newline % Row Count 14 (+ 2) `esac ` \newline % Row Count 15 (+ 1) `while` {\emph{condition}} `; do` {\emph{statements}} `; done` \newline % Row Count 16 (+ 1) `until` {\emph{condition}} `; do` {\emph{statements}} `; done` \newline % Row Count 17 (+ 1) There is also a `select` condition that operates like `case` on user input.% Row Count 19 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Subshell inheritance}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{These are inherited by subshells: \newline % Row Count 1 (+ 1) - the current directory \newline % Row Count 2 (+ 1) - environment variables \newline % Row Count 3 (+ 1) - standard input, output, error, and other open file descriptors \newline % Row Count 5 (+ 2) - signals that are ignored% Row Count 6 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}