Skip to content
This repository was archived by the owner on May 22, 2024. It is now read-only.

nishatrhythm/Operating-Systems

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Operating Systems

Operating Systems related shell scripting can be found here.

Exercises for Shell Scripting

  1. Write a shell script that takes two numbers as input and outputs their sum.
  2. Write a shell script that lists all the files in a directory.
  3. Write a shell script that checks whether a given number is even or odd.
  4. Write a shell script that displays the current date and time.
  5. Write a shell script that counts the number of lines in a given file.
  6. Write a shell script that takes a file name as input and checks whether the file exists or not. If it exists, display a message saying "File exists", otherwise display "File does not exist."
  7. Write a shell script that prompts the user to enter their name, and then greets them with a personalized message.
  8. Write a shell script that calculates the factorial of a given number. The script should take the number as input and display the factorial.
  9. Write a shell script that renames all files in a directory by adding a prefix "new_" to their names. For example, if there are files named "file1.txt" and "file2.txt", the script should rename them to "new_file1.txt" and "new_file2.txt".
  10. Write a shell script that takes a sentence as input and displays the number of words in the sentence.
  11. Write a shell script that takes a directory name as input and counts the number of files and subdirectories in that directory.
  12. Write a shell script that prompts the user to enter a number and calculates the sum of all numbers from 1 to that number.
  13. Write a shell script that checks whether a given string is a palindrome or not.
  14. Write a shell script that finds and displays all the files in a directory that have a specific extension (e.g., ".txt").
  15. Write a shell script that displays the size of the largest file in a directory.
  16. Write a shell script that prompts the user to enter a directory name and recursively lists all files and subdirectories in that directory.
  17. Write a shell script that takes a sentence as input and displays the number of vowels and consonants in the sentence.
  18. Write a shell script that prompts the user to enter a directory name and recursively deletes all empty subdirectories in that directory.
  19. Write a shell script that takes a file name as input and counts the number of words, lines, and characters in that file.
  20. Write a shell script that displays a menu with options for creating, renaming, or deleting files in a directory. Implement the corresponding actions for each option.
  21. Write a shell script that recursively finds and counts the number of files in a directory, including all its subdirectories, and displays the count for each subdirectory.
  22. Write a shell script that finds and displays the top 5 largest files in a directory and its subdirectories.
  23. Write a shell script that takes a directory name as input and recursively finds and lists all files that have been modified within the last 24 hours.
  24. Write a shell script that takes a file name as input and replaces all occurrences of a given word with another word.
  25. Write a shell script that monitors a log file in real-time and displays new lines as they are added to the file.
  26. Write a shell script that takes a directory name as input and creates a compressed archive (e.g., tar.gz) of all the files in the directory, excluding subdirectories.
  27. Write a shell script that prompts the user to enter a directory name and finds all duplicate files (based on content) within that directory.
  28. Write a shell script that takes a file name as input and encrypts its contents using a simple substitution cipher. The script should prompt the user to enter the substitution key.
  29. Write a shell script that monitors the CPU usage of a specific process and sends an email notification if the usage exceeds a certain threshold.
  30. Write a shell script that takes a directory name as input and recursively finds and displays the total disk space used by each user within that directory.


Basics UNIX Commands

1. Open Last Edited File in the Directory

xdg-open "$(ls -t | head -n1)"

2. Print System Information

uname -s
uname -n
uname -r
uname -v
uname -m
uname -i
cat /etc/os-release | grep "PRETTY_NAME"

3. Display File Content in Reverse Order

tac filename.txt

4. Display Current Date (dd/mm/yy)

date +'%d/%m/%y'

5. Display Date and Time (dd-mm-yy/hh.mm.ss)

date +'%d-%m-%y/%H.%M.%S'

6. Copy File from Desktop to Documents Directory

cp ~/Desktop/file.txt ~/Documents/

7. Create a Directory in Pictures

mkdir ~/Pictures/My\ Photos

8. Search for Lines Containing "credit" in a Memo File

grep "credit" memo.txt

9. Combine Contents of Two Files into a New File

cat file1.txt file2.txt > combined.txt

10. Remove Duplicate Lines from a Text File

sort file.txt | uniq > newfile.txt

11. Sort File Contents in Reverse Alphabetical Order

sort -r data.txt

12. Search for the String "the" in myfile.txt

grep "the" myfile.txt

13. Order Files Based on Last Modified Time in Reverse Order

ls -lt --time=atime

14. Recursively Remove Files and Directories

rm -r example

15. Display File Contents with Line Numbers

nl filename.txt

16. Create a Directory called "temp" under Home

mkdir ~/temp

17. View Network Interfaces and Status

ip link show



Assignment

Develop a shell script that simplifies the process of managing files and directories. This script automates common tasks like moving or renaming files, creating new directories, and deleting old files. It provides a basic yet effective solution for organizing and manipulating file systems efficiently.

Features

Menu System

Create a simple menu-driven interface that presents users with options for file and directory management tasks.

File Operations

Move Files: Allow users to move files from one directory to another by specifying the source and destination paths.
Rename Files: Enable users to rename files by providing the current name and the desired new name.

Directory Operations

Create Directories: Allow users to create new directories by specifying the directory name and the parent directory (if applicable).
Delete Directories: Provide an option to delete existing directories, ensuring confirmation before removal.

File Deletion

Delete Files: Allow users to delete specific files by specifying the file name or path.
Delete Old Files: Implement a feature to delete files that haven't been accessed for a specified period.

Error Handling

Basic Error Handling: Include basic error handling mechanisms to handle common errors like invalid inputs or file not found.
Informative Messages: Provide informative error messages to guide users in resolving issues encountered during script execution.

Input Validation

Simple Input Validation: Validate user inputs to ensure they are not empty or contain invalid characters.

Help

Help Option: Include a help option that displays a brief description of the script's functionality and usage instructions.

About

UNIX or Ubuntu Operating Systems related shell scripting and basic commands can be found here.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors