Skip to content

samuelede/auxiliary-projects

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Auxiliary-Projects

Shell Scripting & Miscellaneous

Shell Scripting

You have been learning about Linux for some time, and it is time to start getting a feel of how to automate some work using Shell Scripts.

Welcome to this set of ten shell scripting tasks! This collection of exercises is designed to help you develop your shell scripting skills and deepen your understanding of the fundamentals of working with the command line. Each of the tasks presented here is carefully crafted to challenge your problem-solving abilities and expose you to a wide range of shell scripting concepts and techniques.

By completing these tasks, you will learn how to take user input, perform basic math operations, work with directories and files, create loops, and interact with external websites. You will also learn how to create backups of files, generate random numbers, and convert temperature units. Moreover, by combining these tasks into a single script, you will learn how to structure your code effectively, use conditional statements and loops to control program flow, and write reusable functions.

This set of tasks offers a fun and challenging way to build your skills and develop your proficiency with the command line. So get ready to dive in, learn something new, and have fun along the way!

TASK :


Complete all these 10 tasks into a single shell script

1. Ask the user for their name and age, and output a message with their name and the year they were born.

2. Create a new directory with a name provided by the user, and navigate into it.

3. List all files in the current directory, sorted by file size.

4. Count the number of files in the current directory and output the result.

5. Take a list of numbers as input from the user and output the sum of those numbers.

6. Output a random number between 1 and 100.

7. Create a backup of a specified file by copying it to a backup directory with a timestamp in the filename.

8. Check if a website is online and output a message indicating whether it is up or down.

9. Convert a temperature in Celsius to Fahrenheit, using input from the user.

10. Ask the user for a sentence, then output the sentence in reverse order. For example, if the user enters "Hello, world!", the script should output "!dlrow ,olleH".
  1. Create the project folder called Shell
mkdir Shell
  1. Move into the Shell folder
cd Shell
  1. In the Shell directory, create a file for your Shell script named "script_task.sh"
touch script_task.sh
  1. Copy/write your Shell script into the *"script_task.sh" file using vim editor.
vi script_task.sh

NOTE: You can develop your shell script on a note pad, before copying and paste into the "script_task.sh" file.

  1. Make the script file executable:
chmod +x script_task.sh
  1. Run the script :
sudo ./script_task.sh

About

Shell Scripting & Miscellaneous

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages