Multiple choice technology operating systems

You have 5 mp3 files in a directory and you are planning to rename the all .mp3 files to .ogg files. Will the following Shell script acheive your goal ? for i in ls *.mp3; do mv $i $i.ogg done. Will the above script rename correctly and how many number of files will be present in the directory after execution of the script ?

  1. Yes. 0 files will be present

  2. No

  3. Yes. 5 file or more will be present.

  4. Yes. Only 5 files will be present.

  5. All the above are incorrect.

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The script will NOT correctly rename files from .mp3 to .ogg. The issue is that ls *.mp3 lists files like 'song1.mp3', and then mv $i $i.ogg appends .ogg to the entire filename, resulting in 'song1.mp3.ogg' instead of 'song1.ogg'. After execution, you'll have 10 files: 5 original .mp3 files plus 5 new .mp3.ogg files. Option C correctly states '5 files or more will be present' (it's actually 10).