31: What is the difference between grep and egrep?
egrep is Extended grep that supports added grep features like “+” (1 or more occurrence of previous character),”? ”(0 or 1 occurrence of previous character) and “|” (alternate matching)
32: How will you print the login names of all users on a system?
/etc/shadow file has all the users listed. awk –F ‘:’ ‘{print $1} /etc/shadow’|uniq -u
33: How to set an array in Linux?
Syntax in ksh: Set –A arrayname= (element1 element2 ….. element) In bash A=(element1 element2 element3 …. elementn)
34: Write down the syntax of “for “ loop?
Syntax: for iterator in (elements) do execute commands done
35:How will you find the total disk space used by a specific user?
du -s /home/user1 ….where user1 is the user for whom the total disk space needs to be found.
36: Write the syntax for “if” conditionals in linux?
Syntax If condition is successful then execute commands else execute commands fi
37:What is the significance of $?
? $? gives the exit status of the last command that was executed.
38: How do we delete all blank lines in a file?
sed ‘^ [(backslash)011(backslash)040]*$/d’ file1 where (backslash)011 is octal equivalent of space and (backslash)040 is octal equivalent of tab
39: How will I insert a line “ABCDEF” at every 100th line of a file?
sed ‘100i\ABCDEF’ file1
40: Write a command sequence to find all the files modified in less than 2 days and print the record count of each.?
find . –mtime -2 –exec wc –l {} \;
Tags: Shell Scripting Interview Questions and Answers At Microsoft, Microsoft, Interview Questions and Answers At Microsoft, Shell Scripting, Shell Scripting Interview Questions, Shell Scripting QA, Shell Scripting Interview Questions and Answers, Shell Scripting Tutorial, Shell Scripting books, Shell Scripting Interview Questions pdf, Shell Scripting experienced QA, interview questions, Shell Scripting interview questions for experienced, Shell Scripting interview questions for developers,Shell Scripting interview questions for freshers,Shell Scripting interview questions senior level, Shell Scripting Certification Questions, Basic Shell Scripting interview questions, Shell Scripting interview questions 2 3 4 5 6 years experienced, Shell Scripting Real time interview questions, Shell Scripting Interview Questions and Answers At Microsoft 2015, Latest Shell Scripting Questions At Microsoft Interview, Shell Scripting Technical Interview Questions 4.
egrep is Extended grep that supports added grep features like “+” (1 or more occurrence of previous character),”? ”(0 or 1 occurrence of previous character) and “|” (alternate matching)
32: How will you print the login names of all users on a system?
/etc/shadow file has all the users listed. awk –F ‘:’ ‘{print $1} /etc/shadow’|uniq -u
33: How to set an array in Linux?
Syntax in ksh: Set –A arrayname= (element1 element2 ….. element) In bash A=(element1 element2 element3 …. elementn)
34: Write down the syntax of “for “ loop?
Syntax: for iterator in (elements) do execute commands done
35:How will you find the total disk space used by a specific user?
du -s /home/user1 ….where user1 is the user for whom the total disk space needs to be found.
36: Write the syntax for “if” conditionals in linux?
Syntax If condition is successful then execute commands else execute commands fi
37:What is the significance of $?
? $? gives the exit status of the last command that was executed.
38: How do we delete all blank lines in a file?
sed ‘^ [(backslash)011(backslash)040]*$/d’ file1 where (backslash)011 is octal equivalent of space and (backslash)040 is octal equivalent of tab
39: How will I insert a line “ABCDEF” at every 100th line of a file?
sed ‘100i\ABCDEF’ file1
40: Write a command sequence to find all the files modified in less than 2 days and print the record count of each.?
find . –mtime -2 –exec wc –l {} \;