Shell interview question

Generic but logical solutions needed