Code
Fix Joseph Posted on 1:37 am

Examples of command line usage

You can use the command line to do many different things, from managing a server to searching for files. But all the power shows up when we need to do a lot of the same type of operations.

Let’s imagine the following situation: we downloaded 30 podcasts that we want to listen to on the road. But after downloading, we found out that the volume of all records is very low, and even if you turn everything to maximum, it is still not enough. To listen to the podcasts, we have to:

  • start the audio editor,
  • open each file in turn,
  • manually set the volume to the right level,
  • save the file,
  • open the next one and do the same thing again,
  • repeat 28 more times.

Obviously, this will take a lot of time, and it’s easier to download other podcasts than to spend so much effort on these ones. But in MacOS, for example, we can open a terminal and write two commands there:

cd podcasts
for file in *; do wc -l $file; lame –scale 8 $file; done

The first command goes to the directory with the podcasts and the second

  • takes all the files in that folder;
  • gets their number and name;
  • in the loop starts the program lame and specifies parameters for it – to raise the volume by 8 times for this file;
  • repeats the cycle until all the files are processed.

As a result, we will get the same files in the same folder, but with increased volume. In terms of time, it will be much faster than doing everything manually. But to do that you need to know the features of the command line, know how to work with it, know the commands and their parameters.

Here’s what else you can do through the command line:

  • Monitor processor load;
  • set up program auto-updates;
  • make scheduled backups;
  • generate texts using neuronics and immediately publish the results in your Telegram feed;
  • collect emails from all mailboxes, filter only important emails, collect them in one, arrange it nicely and print it out on a printer;
  • and anything else, if there is a command or parameter to call for it.