Chapter 3 Challenges

From Linux Shell Scripting Tutorial - A Beginner's handbook
Jump to: navigation, search
← Setting system wide shell optionsHomeChapter 4: Conditionals Execution (Decision Making) →
  1. Make a backup of existing variable called PS1 to OLDPS1. Set PS1 to '$'. Reset your prompt using OLDPS1 variable.
  2. Customize your bash prompt by setting PS1 variable to 'I Love Scripting '.
  3. Edit your $HOME/.bashrc file and set your new PS1 variable.
  4. Create a list of legal and illegal bash variable names. Describe why each is either legal or illegal.
  5. Write a command to display the environment.
  6. Write a shell script that allows a user to enter his or her top three ice cream flavors. Your script should then print out the name of all three flavors.
  7. Write a shell script that allows a user to enter any Internet domain name (host name such as www.cyberciti.biz). Your script should than print out the IP address of the Internet domain name.
  8. Write a shell script that allows a user to enter any existing file name. The program should then copy file to /tmp directory.
  9. Write a shell script that allows a user to enter directory name. The program should then create directory name in /tmp directory.
  10. Write a shell script that allows a user to enter three file names. The program should then copy all files to USB pen.
  11. Write a simple shell script where the user enters a pizza parlor bill total. Your script should then display a 10 percent tip.
  12. Write a simple calculator program that allows user to enter two numeric values and operand as follows. The program should then print out the sum of two numbers. Make sure it works according to entered operand.
Enter two values : 10 20
Enter operand ( +, -, /, *) : +
Output: 10 + 20 = 30
← Setting system wide shell optionsHomeChapter 4: Conditionals Execution (Decision Making) →