+</code></pre><p>The character at which the tab key is pressed in the above example has been cherry picked for illustration purposes. The number of steps would increase if you try pressing tab after each character. With experience, using the tab key for autocompletion will become a natural part of your command line usage.<blockquote><p><img alt=info src=./images/info.svg> You can set an option to combine the features of single and double tab presses into a single tab press. This will be discussed in the <a href=./shell-customization.html>Shell Customization</a> chapter.</blockquote><h2 id=real-world-use-cases><a class=header href=#real-world-use-cases>Real world use cases</a></h2><p>If the command line environment only had file managing features, I'd still use it. Given the wide variety of applications available, I can't imagine going back to using a different GUI application for each use case. My primary work is writing ebooks, blog posts and recording videos. Here are the major CLI tools I use:<ul><li>text processing using <code>head</code>, <code>tail</code>, <code>sort</code>, <code>grep</code>, <code>sed</code>, <code>awk</code> and so on (you'll learn about these commands in later chapters)<li><a href=https://git-scm.com/>git</a> — version control<li><a href=https://github.com/jgm/pandoc/>pandoc</a> — generating PDF/EPUB book versions from markdown files<li><a href=https://github.com/rust-lang/mdBook>mdBook</a> — web version of the books from markdown files<li><a href=https://github.com/getzola/zola>zola</a> — static site generator<li><a href=https://imagemagick.org/index.php>ImageMagick</a> — image processing like resizing, adding borders, etc<li><a href=https://github.com/shssoichiro/oxipng>oxipng</a>, <a href=https://pngquant.org/>pngquant</a> and <a href=https://github.com/RazrFalcon/svgcleaner>svgcleaner</a> — optimizing images<li><a href=https://github.com/WyattBlue/auto-editor>auto-editor</a> — removing silent portions from video recordings<li><a href=https://github.com/FFmpeg/FFmpeg>FFmpeg</a> — video processing, padding for example (<code>FFmpeg</code> is also a major part of the <code>auto-editor</code> solution)</ul><p>Some of these workflows require additional management, for which I write shell functions or scripts. I do need GUI tools as well, for example, web browser, image viewer, PDF/EPUB viewers, <a href=https://github.com/MaartenBaert/ssr>SimpleScreenRecorder</a> and so on. Some of these can be handled from within the terminal too, but I prefer GUI for such cases. I do launch some of them from the terminal, primarily for providing the file or url to be opened.<p>You might wonder what advantage does the command line provide for processing images and videos? Apart from being faster, the custom parameters (like border color, border size, quality percentage, etc) are automatically saved as part of the scripts I create. After that, I can just use a single call to the script instead of waiting for a GUI application to open, navigating to required files, applying custom parameters, saving them after all the required processing is done, closing the application, etc. Also, that single script can use as many tools as needed, whereas with GUI you'll have to repeat such steps with different applications.<h2 id=exercises><a class=header href=#exercises>Exercises</a></h2><blockquote><p><img alt=info src=images/info.svg> <img alt=info src=./images/info.svg> All the exercises are also collated together in one place at <a href=https://github.com/learnbyexample/cli-computing/blob/master/exercises/exercises.md>exercises.md</a>. For solutions, see <a href=https://github.com/learnbyexample/cli-computing/blob/master/exercises/exercise-solutions.md>exercise-solutions.md</a>.</blockquote><p><strong>1)</strong> By default, is <code>echo</code> a shell builtin or external command on your system? What command could you use to get an answer for this question?<p><strong>2)</strong> What output do you get for the command shown below? Does the documentation help understand the result?<pre><code class=language-bash>$ echo apple 42 'banana 100'
0 commit comments