ls -a /usr | grep '^[prs]'
Select from the output ls -a /usr (which is a list of files in /usr , separated by newlines), lines starting with the characters p , r or s .
Your teacher probably expects, but this is wrong or at least not reliable.
File names can be made up of many lines, as the newline character is as a valid character, like any in a file name on Linux or any unix. Thus, the command does not return files whose name begins with p , q or s , but file name strings starting with p , q or s . As a rule, you cannot reliably execute the output of ls .
-a must include hidden files, that is, files whose name begins with . . Since you only need those that start with p , q or s , this is redundant.
Note that:
ls /usr | grep ^[pqs]
will be even more erroneous. The first ^ is a special character in several shells, such as the Bourne, rc , es or zsh -o extendedglob bash (although OK in bash or other POSIX shells).
Then in most shells ( fish is the notable exception), [pqs] is the globbing operator. This means that ^[qps] supposed to be expanded by the shell into a list of files matching this pattern (relative to the current directory).
So, in those shells like bash that are not specifically related to ^ if there is a file in the current directory called ^p that will become
ls /usr | grep ^p
If there is no corresponding file, in csh , tcsh , zsh or bash -O failglob you will receive an error message and the command will be canceled. In zsh -o extendedglob , where ^ is the globbing operator, ^[pqs] will mean any file, but p , q or s .