We have some images under the directory /home/bob/images. Develop a script /home/bob/rename-images.sh to rename all files within the images folder that has extension jpeg to jpg. A file with any other extension should remain the same. Tip: Use a for loo

#!/bin/bash

for i in $(ls /home/bob/images)
do
if [[ $i =~ *.jpeg ]]
then
n=$(echo $i| sed ‘s/jpeg/jpg/g’)
mv /home/bob/images/$i /home/bob/images/$n
# mv – $i “$i.html”
f

Hi @vijayalakshmi_revur

It looks like there are a few issues with the script you provided. For instance, you’re using =~ for pattern matching, which is mostly used with grep, and the pattern should be quoted, which you haven’t. Additionally, I noticed that the if conditional block is missing its closing statement, and there’s no done to signify the end of the for loop.

If you could share the link to the lab you are working on, I would be better able to suggest a fix or provide you with an updated script.

Regards.