Multiple choice technology operating systems

How can you list the files present in a directory in alphabetical order ?

  1. ls -S

  2. By executing the script - for myfile in * do echo "$myfile" done
  3. ls -t

  4. a,b and c are correct

  5. a is incorrect and b is correct

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

By default, shell globbing with * expands filenames in alphabetical order, so the loop in option b will print them alphabetically. Option a (ls -S) sorts by file size, and c (ls -t) sorts by modification time, making them incorrect. Thus, b is correct while a is not.