\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{Rudi} \pdfinfo{ /Title (tiny-helpers-for-awk-sed-vim-and-script.pdf) /Creator (Cheatography) /Author (Rudi) /Subject (Tiny helpers for awk, sed, vim and script 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}{A3A3A3} \definecolor{LightBackground}{HTML}{F3F3F3} \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{Tiny helpers for awk, sed, vim and script Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Rudi} via \textcolor{DarkBackground}{\uline{cheatography.com/56130/cs/46012/}}} \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}Rudi \\ \uline{cheatography.com/rudi} \\ \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 28th March, 2025.\\ 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{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Introducion}} \tn \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{I know the tools and the syntax. But I don't use it every day and when I have to use it, I'm starting nearly at the beginning. I hope the following (partial or merged) helps me to get an idea and start faster to find a solution. Maybe you too?! \newline % Row Count 5 (+ 5) Simple try it and look what you get :) \newline % Row Count 6 (+ 1) Made with current versions in 2025 (Ubuntu LTS https://ubuntu.com; GNU utilities for Windows \seqsplit{https://unxutils.sourceforge.net).}% Row Count 9 (+ 3) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{AWK (octal, hex)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{{\bf{From:}} ~ ~ ~ ~ ~ ~ ~ {\bf{To:}} \newline % Row Count 2 (+ 2) yin \& yang ~ ~ ~ ~yin and yang \newline % Row Count 4 (+ 2) ~ \newline % Row Count 5 (+ 1) {\bf{Lnx:}} echo -e yin '\textbackslash{}0046' yang | awk '\{gsub(/\textbackslash{}x26/, "and"); print \$0\}' \newline % Row Count 7 (+ 2) {\bf{Win:}} echo.exe yin \textbackslash{}046 yang | gawk.exe "\{gsub(/\textbackslash{}x26/, \textbackslash{}"and\textbackslash{}"); print \$0\}"% Row Count 9 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{SED (octal, hex)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{{\bf{From:}} ~ ~ ~ ~ ~ ~ ~ ~{\bf{To:}} \newline % Row Count 2 (+ 2) yin \& yang ~ ~ ~ ~ yin and yang \newline % Row Count 4 (+ 2) ~ \newline % Row Count 5 (+ 1) {\bf{Lnx:}} echo -e yin '\textbackslash{}0046' yang | sed 's/\textbackslash{}x26/and/' \newline % Row Count 7 (+ 2) {\bf{Win:}} echo.exe yin \textbackslash{}046 yang | sed.exe "s/\textbackslash{}x26/and/"% Row Count 9 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{AWK (Conditions)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{{\bf{From:}} ~ ~ ~ ~{\bf{To:}} \newline % Row Count 1 (+ 1) 1 ~ ~ ~ ~ ~ ~ ~ Line 2: 2 \newline % Row Count 3 (+ 2) 2 ~ ~ ~ ~ ~ ~ ~ Line 3: 3 \newline % Row Count 5 (+ 2) 3 ~ ~ ~ ~ ~ ~ ~ Line 5: 5 \newline % Row Count 7 (+ 2) 4 \newline % Row Count 8 (+ 1) 5 \newline % Row Count 9 (+ 1) ~ \newline % Row Count 10 (+ 1) {\bf{Lnx:}} echo -e '1\textbackslash{}n2\textbackslash{}n3\textbackslash{}n4\textbackslash{}n5' | awk '\{if(\$0 \textgreater{} 1 \&\& \$0 \textless{}= 5 \&\& NR != 4) print "Line " NR ": " \$0\}' \newline % Row Count 13 (+ 3) {\bf{Win:}} echo.exe 1\textbackslash{}n2\textbackslash{}n3\textbackslash{}n4\textbackslash{}n5 | gawk.exe "\{if(\$0 \textgreater{} 1 \&\& \$0 \textless{}= 5 \&\& NR != 4) print \textbackslash{}"Line \textbackslash{}" NR \textbackslash{}": \textbackslash{}" \$0\}"% Row Count 16 (+ 3) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{AWK (Substring)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{{\bf{From:}} ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~{\bf{To:}} \newline % Row Count 2 (+ 2) wvvw.google.de ~ ~ ~wvvw.google.com \newline % Row Count 4 (+ 2) ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~google \newline % Row Count 7 (+ 3) ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~go-away \newline % Row Count 10 (+ 3) ~ \newline % Row Count 11 (+ 1) {\bf{Lnx:}} echo wvvw.google.com | awk 'BEGIN\{FS="."\}\{print \$0; print \$2; print substr(\$2, 1, 2)"-away"\}' \newline % Row Count 14 (+ 3) {\bf{Win:}} echo.exe wvvw.google.com | gawk.exe "BEGIN\{FS=\textbackslash{}".\textbackslash{}"\}\{print \$0; print \$2; print substr(\$2, 1, 2)\textbackslash{}"-away\textbackslash{}"\}"% Row Count 17 (+ 3) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{SED (Substring)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{{\bf{From:}} ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ {\bf{To:}} \newline % Row Count 2 (+ 2) wvvw.google.de ~ ~ ~ go-away \newline % Row Count 3 (+ 1) ~ \newline % Row Count 4 (+ 1) {\bf{Lnx:}} echo wvvw.google.com | sed `'s/\textasciicircum{}.{\emph{\textbackslash{}.\textbackslash{}(..\textbackslash{}).}}\textbackslash{}..*/\textbackslash{}1-away/'` \newline % Row Count 6 (+ 2) {\bf{Win:}} echo.exe wvvw.google.com | `sed.exe "s/\textasciicircum{}.{\emph{\textbackslash{}.\textbackslash{}(..\textbackslash{}).}}\textbackslash{}..*/\textbackslash{}1-away/"`% Row Count 8 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{AWK (System call)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{{\bf{From:}} ~ ~ ~ {\bf{To:}} \newline % Row Count 1 (+ 1) Time:~ ~ ~ ~ Time: hh:mm \newline % Row Count 2 (+ 1) ~ \newline % Row Count 3 (+ 1) {\bf{Lnx:}} echo "Time: " | awk '\{system("date +\%R" | getline m); print \$0 m\}' 2\textgreater{}/dev/null \newline % Row Count 5 (+ 2) {\bf{Win:}} echo.exe Time: | gawk.exe "\{system(\textbackslash{}"time /t\textbackslash{}" | getline m); print \$0 m\}" 2\textgreater{}NUL% Row Count 7 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{AWK (Substitution, mult.)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{{\bf{From:}} ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ {\bf{To:}} \newline % Row Count 3 (+ 3) E4-54-E8-6D-31-AA ~ ~ ~ {[}subst cnt{]} e4:54:e8:6d:31:aa \newline % Row Count 5 (+ 2) ~ \newline % Row Count 6 (+ 1) {\bf{Lnx:}} echo E4-54-E8-6D-31-AA | awk '\{print gsub("-", ":"); print tolower(\$0)\}' \newline % Row Count 8 (+ 2) {\bf{Win:}} echo.exe E4-54-E8-6D-31-AA | gawk.exe "\{print gsub(\textbackslash{}"-\textbackslash{}", \textbackslash{}":\textbackslash{}"); print tolower(\$0)\}"% Row Count 10 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{SED (Substitution, mult.)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{{\bf{From:}} ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ {\bf{To:}} \newline % Row Count 3 (+ 3) E4-54-E8-6D-31-AA ~ ~ ~ e4:54:e8:6d:31:aa \newline % Row Count 5 (+ 2) ~ \newline % Row Count 6 (+ 1) {\bf{Lnx:}} echo E4-54-E8-6D-31-AA | sed 's/-/:/g; s/\textasciicircum{}\textbackslash{}(.*\textbackslash{})\$/\textbackslash{}L\&/' \newline % Row Count 8 (+ 2) {\bf{Win:}} echo.exe E4-54-E8-6D-31-AA | sed.exe "s/-/:/g; s/\textasciicircum{}\textbackslash{}(.*\textbackslash{})\$/\textbackslash{}L\&/"% Row Count 10 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{AWK (printf)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{{\bf{From:}} ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ {\bf{To:}} \newline % Row Count 4 (+ 4) dummy1-dummy2 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Six \textbackslash{} Two ~ ~ ~ = ~ ~ ~ ~ ~3.00 \newline % Row Count 9 (+ 5) ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 123456789 ~ ~123456 ~ ~ ~ 1234567 \newline % Row Count 15 (+ 6) ~ \newline % Row Count 16 (+ 1) {\bf{Lnx:}} echo dummy1-dummy2 | awk 'BEGIN\{FS="-"; equ="="; bsl="\textbackslash{}\textbackslash{}"\}\{V1="Six"; V2="Two"; V3=3; printf(" \%+9s \%s \%-6s \%s \%7.2f\textbackslash{}n", V1, bsl, V2, equ, V3)\}END\{print " 123456789 123456 1234567"\}' \newline % Row Count 21 (+ 5) {\bf{Win:}} echo.exe dummy1-dummy2 | gawk.exe "BEGIN\{FS=\textbackslash{}"-\textbackslash{}"; equ=\textbackslash{}"=\textbackslash{}"; bsl=\textbackslash{}"\textbackslash{}\textbackslash{} \textbackslash{}"\}\{V1=\textbackslash{}"Six\textbackslash{}"; V2=\textbackslash{}"Two\textbackslash{}"; V3=3; printf(\textbackslash{}" \%+9s \%s \%-6s \%s \%\#7.2f\textbackslash{}n\textbackslash{}", V1, bsl, V2, equ, V3)\}END\{print \textbackslash{}" 123456789 123456 1234567\textbackslash{}"\}"% Row Count 26 (+ 5) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{VIM (Sort file, system call)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{{\bf{From:}} ~ ~ ~ ~ ~ ~ ~ ~ ~{\bf{To:}} \newline % Row Count 2 (+ 2) bravo ~ ~ ~ ~ ~ ~ ~ ~ ~ alpha \newline % Row Count 4 (+ 2) delta ~ ~ ~ ~ ~ ~ ~ ~ ~ ~bravo \newline % Row Count 6 (+ 2) alpha ~ ~ ~ ~ ~ ~ ~ ~ ~ bravo \newline % Row Count 8 (+ 2) bravo ~ ~ ~ ~ ~ ~ ~ ~ ~ charlie \newline % Row Count 10 (+ 2) charlie ~ ~ ~ ~ ~ ~ ~ ~ delta \newline % Row Count 12 (+ 2) echo ~ ~ ~ ~ ~ ~ ~ ~ ~ ~echo \newline % Row Count 14 (+ 2) foxtrot ~ ~ ~ ~ ~ ~ ~ ~ ~echo \newline % Row Count 16 (+ 2) echo ~ ~ ~ ~ ~ ~ ~ ~ ~ ~echo \newline % Row Count 18 (+ 2) echo ~ ~ ~ ~ ~ ~ ~ ~ ~ ~foxtrot \newline % Row Count 20 (+ 2) ~ \newline % Row Count 21 (+ 1) {\bf{Lnx/Win:}} :1,\$ !sort% Row Count 22 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{VIM (Remove duplicate lines from sorted file)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{{\bf{From:}} ~ ~ ~ ~ ~ ~ ~ ~ ~{\bf{To:}} \newline % Row Count 2 (+ 2) alpha ~ ~ ~ ~ ~ ~ ~ ~ ~ alpha \newline % Row Count 4 (+ 2) bravo ~ ~ ~ ~ ~ ~ ~ ~ ~ bravo \newline % Row Count 6 (+ 2) bravo ~ ~ ~ ~ ~ ~ ~ ~ ~ charlie \newline % Row Count 8 (+ 2) charlie ~ ~ ~ ~ ~ ~ ~ ~ delta \newline % Row Count 10 (+ 2) delta ~ ~ ~ ~ ~ ~ ~ ~ ~ ~echo \newline % Row Count 12 (+ 2) echo ~ ~ ~ ~ ~ ~ ~ ~ ~ ~foxtrot \newline % Row Count 14 (+ 2) echo \newline % Row Count 15 (+ 1) echo \newline % Row Count 16 (+ 1) foxtrot \newline % Row Count 17 (+ 1) ~ \newline % Row Count 18 (+ 1) {\bf{Lnx/Win:}} :\%s/\textasciicircum{}\textbackslash{}(.*\textbackslash{})\textbackslash{}(\textbackslash{}n\textbackslash{}1\textbackslash{})\textbackslash{}+\$/\textbackslash{}1/% Row Count 19 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{VIM (Rearrangement, assign states to regions)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{{\bf{From:}} ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~{\bf{To:}} \newline % Row Count 3 (+ 3) AMER {\emph{tab}} Canada ~ ~ ~ ~ ~ ~ AMER {\emph{tab}} Canada \newline % Row Count 5 (+ 2) APAC {\emph{tab}} China ~ ~ ~ ~ ~ ~ ~ ~ APAC {\emph{tab}} China {\emph{tab}} Japan \newline % Row Count 8 (+ 3) APAC {\emph{tab}} Japan ~ ~ ~ ~ ~ ~ ~ ~ EMEA {\emph{tab}} Lebanon {\emph{tab}} Senegal {\emph{tab}} Spain \newline % Row Count 11 (+ 3) EMEA {\emph{tab}} Lebanon \newline % Row Count 12 (+ 1) EMEA {\emph{tab}} Senegal \newline % Row Count 13 (+ 1) EMEA {\emph{tab}} Spain \newline % Row Count 14 (+ 1) ~ \newline % Row Count 15 (+ 1) {\bf{Lnx/Win:}} :\%s/\textasciicircum{}\textbackslash{}(..{\emph{\textbackslash{})\textbackslash{}t\textbackslash{}(..}}\$\textbackslash{})\textbackslash{}(\textbackslash{}n\textbackslash{}1\textbackslash{})\textbackslash{}+\textbackslash{}t\textbackslash{}(..*\$\textbackslash{})/\textbackslash{}1\textbackslash{}t\textbackslash{}2\textbackslash{}t\textbackslash{}4/ \newline % Row Count 17 (+ 2) ~ ~ ~ ~ ~ ~ ~ ~{[}Repeat until "Pattern not found"{]}% Row Count 19 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Some Bash script}} \tn \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{\#!/bin/bash \newline % Row Count 1 (+ 1) hh=\textbackslash{}`date +\%H\textbackslash{}` \newline % Row Count 2 (+ 1) echo "Current hour:" \$hh \newline % Row Count 3 (+ 1) read -p 'Hour to search for (x=Exit)?: ' hour \newline % Row Count 4 (+ 1) \# \textbackslash{}\textless{} \textbackslash{}\textgreater{} to supress hits of a single digit in a two digit hour \newline % Row Count 6 (+ 2) echo \$hh | grep "\textbackslash{}\textless{}\$hour\textbackslash{}\textgreater{}" \textgreater{}/dev/null \newline % Row Count 7 (+ 1) RetCode=\$? \newline % Row Count 8 (+ 1) if {[} \$hour == "x" {]}; then \newline % Row Count 9 (+ 1) ~ ~ exit \newline % Row Count 10 (+ 1) elif {[} \$RetCode -eq 0 {]}; then \newline % Row Count 11 (+ 1) ~ ~ echo "\$hh eq \$hour Hit" \newline % Row Count 12 (+ 1) elif {[} \$RetCode -eq 1 {]}; then \newline % Row Count 13 (+ 1) ~ ~ echo "\$hh neq \$hour noHit" \newline % Row Count 14 (+ 1) fi \newline % Row Count 15 (+ 1) a=\textbackslash{}`expr \$hour + 1\textbackslash{}` \newline % Row Count 16 (+ 1) echo -e "\$hour + 1 =" \$a "\textbackslash{}n"% Row Count 17 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Some Batch script}} \tn \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{@echo off \newline % Row Count 1 (+ 1) REM Some echo. commands would make it nicer ... \newline % Row Count 2 (+ 1) cls \newline % Row Count 3 (+ 1) set hh=\%time:\textasciitilde{}-11,2\% \newline % Row Count 4 (+ 1) if \%hh\% LSS 10 set hh=0\%time:\textasciitilde{}-10,1\% \newline % Row Count 5 (+ 1) echo Current hour: \%hh\% \newline % Row Count 6 (+ 1) set /P hour=Hour to search for (x=Exit)?: \newline % Row Count 7 (+ 1) :: Brackets to identify blank input. \newline % Row Count 8 (+ 1) if {[}\%hour\%{]}=={[}x{]} goto :EOF \newline % Row Count 9 (+ 1) echo \%hh\% | find "\%hour\%" \textgreater{}NUL \newline % Row Count 10 (+ 1) if errorlevel 1 echo \%hh\% neq \%hour\% noHit \newline % Row Count 11 (+ 1) if not errorlevel 1 echo \%hh\% equ \%hour\% Hit \newline % Row Count 12 (+ 1) for /f \%\%d in ('date /T') do set dat=\%\%d \newline % Row Count 13 (+ 1) echo \%dat\% \newline % Row Count 14 (+ 1) if \%dat\% NEQ "01.01.1970" set /a sum=1+1 \newline % Row Count 15 (+ 1) echo 1+1=\%sum\% \newline % Row Count 16 (+ 1) pause% Row Count 17 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Some Vim script}} \tn \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{" Execute: vim -S this.script \newline % Row Count 1 (+ 1) :function! IN() \newline % Row Count 2 (+ 1) : ~ ~ call inputsave() \newline % Row Count 3 (+ 1) : ~ ~ let @i = input('Hour to search for?: ') \newline % Row Count 5 (+ 2) : ~ ~ call inputrestore() \newline % Row Count 6 (+ 1) :endfunction \newline % Row Count 7 (+ 1) :let hh=strftime("\%H") \newline % Row Count 8 (+ 1) :echo "Current hour:" hh \newline % Row Count 9 (+ 1) :call IN() \newline % Row Count 10 (+ 1) :let hour = @i \newline % Row Count 11 (+ 1) :if hh == hour \newline % Row Count 12 (+ 1) : ~ ~ echo "\textbackslash{}n" hh "equ" hour "Hit" \newline % Row Count 13 (+ 1) :elseif hh != hour \newline % Row Count 14 (+ 1) : ~ ~ echo "\textbackslash{}n" hh "neq" hour "noHit" \newline % Row Count 15 (+ 1) :endif \newline % Row Count 16 (+ 1) :let a = hour + 1 \newline % Row Count 17 (+ 1) :echo hour "+ 1 =" a% Row Count 18 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \end{document}