Vous êtes sur la page 1sur 4

UNIX and Linux – Quiz 7 

Name:    Date:   

Quiz 7: Writing a shell script 
 
1. Your supervisor wants you to create a shell script on the Linux computer that helps determine the 
volume  of  a  box  after  we  prompt  the  user  for  the  length,  width  and  height  in  cubic  inches.  The 
formula  for  the  volume  of  a  box  is  V=LxWxH.  The  manager  also  wants  you  to  convert  the  cubic 
inches to cubic centimeters by using the conversion factor of 16.387064 cubic centimeters in a cubic 
inch. Please add comments throughout the program. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 


 
UNIX and Linux – Quiz 7 

2. The  supervisor  needs  you  to  prompt  the  user  for  the  name  of  the  file  to  create  in  the  Linux 
computer.  However,  we  need  to  check  that  the  file  name  is  not  database.  If  the  file  is  called 
database,  tell  them  of  the  error  and  ask  them  for  a  new  file  name.  On  the  second  condition 
statement, if the file is not equal to database then we will create the file using the expression touch 
filename.txt. If the name is still database, we tell them that the file was not created. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 


 
UNIX and Linux – Quiz 7 

3. The  supervisor  would  like  you  to  create  a  list  with  our  sales  offices  in  it  for  quick  reference.  The 
offices  are  in  Albany,  Cleveland,  Chicago,  Atlanta,  Houston,  Seattle,  Miami,  Sacramento  and 
Anchorage.  Please put the list in alphabetical order. 
 


 
UNIX and Linux – Quiz 7 

4. The  supervisor  would  like  you  to  create  a  shell  script  that  prompts  the  computer  user  how  many 
files they would like to make. Set that number to the variable total. Set the counter to zero. In the 
loop,  ask  for  the  file  name  and  then  on  the  next  line,  create  a  text  file  using  the  touch  Bash 
command such as touch filename.txt. On the next line, add one to the counter. 
 


 

Vous aimerez peut-être aussi