Menu
Coddy logo textTech

Getting The Source Path

Part of the Fundamentals section of Coddy's Terminal journey. Lesson 75 of 82.

challenge icon

Challenge

Easy

Let's start building the backup script! The first step is to create a script that asks the user for the source directory they want to back up.

Create a shell script called backup.sh that:

  1. Starts with the shebang line (#!/bin/bash)
  2. Uses read -p to prompt the user with: Enter source directory:
  3. Stores the user's input in a variable called source_dir
  4. Prints the message: Backing up: [source_dir]

Make the script executable. Then run it and enter documents when prompted.

Your final output should be:

Backing up: documents

Hint: Use read -p "Enter source directory: " source_dir to display the prompt and capture input in one line. Remember to use chmod +x to make the script executable before running it with ./backup.sh.

Try it yourself

Terminal
cat server.log

All lessons in Fundamentals

Practice on your own: Terminal playground