...

/

Exercise: Bash Features

Exercise: Bash Features

Practice writing a command using logical operators. The solution for the given question will also be discussed.

We'll cover the following...

Practice

Write the command that implements the following algorithm:

  1. Copy the /usr/share/doc/bash/README file to the home directory.

  2. Archive the copied ~/README file.

  1. Delete the copied ~/README file.

Each step takes place only if the previous one succeeds. We write the result of each step to the log file result.txt.

Terminal 1
Terminal
Loading...

Solution

Let’s implement the algorithm step by step. The first action is to copy the README file to the user’s home directory like so:

cp /usr/share/doc/bash/README ~

We use the && operator and the echo command to print the ...