41) Write a command that will display files in the current directory, in a colored, long format.?
Answer: ls -l –color
42) Write a command that will find all text files in a directory such that it does not contain the word “amazing” in any form (that is, it must include the words Amazing, AMAZING, or aMAZINg)?
Answer: grep –vi amazing *.txt
43) Write a command that will output the sorted contents of a file named IN.TXT and place the output in another file named OUT.TXT, while at the same time excluding duplicate entries.?
Answer: sort IN.TXT | uniq > OUT.TXT
44) Write a command that will allow a UNIX system to shut down in 15 minutes, after which it will perform a reboot.?
Answer: /sbin/shutdown –r +15
45) What command will change your prompt to MYPROMPT: ?
To change a prompt, we use the PS1 command, such as this: PS1 = ‘MYPROMPT:’
46) What does this command do?
cat food 1 > kitty Answer: it redirects the output of cat food into the file kitty; the command is the same as: cat food > kitty
47) What is wrong with this interactive shell script?
echo What month is this?
read $month echo $month is as good a month as any. Answer: Initially, the question mark should be escaped (\?
) so that it is not interpreted as a shell metacharacter. Second, it should be read month, not read $month.
48) Write a shell script that requests the user’s age and then echoes it, along with some suitable comment.?
Answer: echo Hello! What\’s your age\?
read age
echo $age! I\’ll be obsolete by that age!
49) Write a script that prints out date information in this order: time, day of week, day number, month, year (sample output: 13:35:11 PDT Sun 10 Feb 2010)?
Answer: set ‘date’
echo $4 $5 $1 $3 $2 $6
50) Write a script that will show the following as output: Give me a U! U! Give ma a N! N! Give me a I! I! Give me a X! X!?
Answer: for i in U N I X do
echo Give me a $i!
echo $i! done
Tags: Unix 5, Unix Interview Questions, Unix QA, Unix Interview Questions and Answers, Unix Tutorial, Unix books, Unix Interview Questions pdf, Unix experienced, interview questions, Unix interview questions for experienced, Unix interview questions for developers,Unix interview questions for freshers,Unix interview questions senior level, Unix Certification Questions, Basic Unix interview questions, Unix interview questions 2 3 4 5 6 years experienced, Unix Real time interview questions, Unix Experienced Level Interview Questions, Advanced Unix Interview Questions and Answers, Unix Experienced Interview Questions.
Answer: ls -l –color
42) Write a command that will find all text files in a directory such that it does not contain the word “amazing” in any form (that is, it must include the words Amazing, AMAZING, or aMAZINg)?
Answer: grep –vi amazing *.txt
43) Write a command that will output the sorted contents of a file named IN.TXT and place the output in another file named OUT.TXT, while at the same time excluding duplicate entries.?
Answer: sort IN.TXT | uniq > OUT.TXT
44) Write a command that will allow a UNIX system to shut down in 15 minutes, after which it will perform a reboot.?
Answer: /sbin/shutdown –r +15
45) What command will change your prompt to MYPROMPT: ?
To change a prompt, we use the PS1 command, such as this: PS1 = ‘MYPROMPT:’
46) What does this command do?
cat food 1 > kitty Answer: it redirects the output of cat food into the file kitty; the command is the same as: cat food > kitty
47) What is wrong with this interactive shell script?
echo What month is this?
read $month echo $month is as good a month as any. Answer: Initially, the question mark should be escaped (\?
) so that it is not interpreted as a shell metacharacter. Second, it should be read month, not read $month.
48) Write a shell script that requests the user’s age and then echoes it, along with some suitable comment.?
Answer: echo Hello! What\’s your age\?
read age
echo $age! I\’ll be obsolete by that age!
49) Write a script that prints out date information in this order: time, day of week, day number, month, year (sample output: 13:35:11 PDT Sun 10 Feb 2010)?
Answer: set ‘date’
echo $4 $5 $1 $3 $2 $6
50) Write a script that will show the following as output: Give me a U! U! Give ma a N! N! Give me a I! I! Give me a X! X!?
Answer: for i in U N I X do
echo Give me a $i!
echo $i! done