What you will build
Step 1: List matching names with a NUL-safe loop
The directory photos holds three entries, including one with a space. The loop reads each name whole, and the case statement keeps the names that contain the word draft. Run this in /workspace.
cd /workspace/photos
while IFS= read -r -d '' f; do
case ${f##*/} in
*draft*) printf '%s\n' "${f##*/}" ;;
esac
done < <(find . -mindepth 1 -maxdepth 1 -print0) > /workspace/plan.txtRun cat /workspace/plan.txt. It should list two names, one with a space and one with a dash.
Step 2: Rename matches with mv and quoted names
A glob is safe for this job because each matching name arrives as one word. The end-of-options marker protects names that begin with a dash, and the quotes protect the space. Run this in /workspace.
cd /workspace/photos
for f in *draft*; do mv -- "$f" "${f//draft/done}"; doneRun ls in the photos directory. You should see done one.txt and done-two.txt, and final.txt unchanged.
Step 3: Skip a rename when the target exists
The directory photos holds draft-x.txt and done-x.txt. Renaming the first to the second would overwrite the existing file, so the script must test first. This branch records the skip instead of moving the file.
cd /workspace/photos
if [ -e done-x.txt ]; then
echo 'skip: done-x.txt exists' > /workspace/conflict.txt
else
mv -- draft-x.txt done-x.txt
fiRun cat /workspace/conflict.txt. The draft file should still be there.
Files
walkthrough.sh: every step of the reference solution, in order.
How it is checked
Each step in the guided lab has a check script that runs on the lab machine after you finish. It passes only when the files and output it expects are there, so the lab cannot be completed by reading alone.