...

/

Backup Command Example

Backup Command Example

Learn the features of Bash scripts by considering an example.

We'll cover the following...

Backup command

We need an example to consider Bash scripts’ features. Let’s write the command that creates a backup of our photos in the home directory. The command consists of two actions: archiving and copying.

Let’s suppose that we store all our photos in the ~/photo directory. We want to save them in ~/backup. Then, the following command creates an archive of the photos there:

tar -cjf ~/photo.tar.bz2 ~/photo && cp -f ~/photo.tar.bz2 ~/backup

Run the commands discussed in this lesson in the terminal below.

Terminal 1
Terminal
Loading...

Here, the logical AND connects the archiving and ...