#!/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
#!/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
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.