Shell Interview Question

Generic but logical solutions needed