Skip to main content

Posts

UNIX Shell Interview Questions

UNIX Shell 1. How will you remove all files in current directory? Including the files that are two levels down in a subdirectory. In Unix we have rm command to remove files and sub-directories. With rm command we have –r option that stands for recursive. The –r option can delete all files in a directory recursively. It means if we our current directory structure is as follows: My_dir ->Level_1_dir -> Level_1_dir ->Level_2_dir -> Level_1_dir ->Level_2_dir->a.txt With rm –r * command we can delete the file a.txt as well as subdirectories Level_1_dir and Level_2_dir. Command: rm – r * The asterisk (*) is a wild card character that stands for all the files with any name. 2. What is the difference between the –v and –x options in Bash shell scripts? In a BASH Unix shell we can specify the options –v and –x on top of a script as follows: #!/bin/bash -x –v With –x option BASH shell will echo the commands like for, select, case etc. after subst