Operating Systems related shell scripting can be found here.
- Write a shell script that takes two numbers as input and outputs their sum.
- Write a shell script that lists all the files in a directory.
- Write a shell script that checks whether a given number is even or odd.
- Write a shell script that displays the current date and time.
- Write a shell script that counts the number of lines in a given file.
- 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."
- Write a shell script that prompts the user to enter their name, and then greets them with a personalized message.
- Write a shell script that calculates the factorial of a given number. The script should take the number as input and display the factorial.
- 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".
- Write a shell script that takes a sentence as input and displays the number of words in the sentence.
- Write a shell script that takes a directory name as input and counts the number of files and subdirectories in that directory.
- Write a shell script that prompts the user to enter a number and calculates the sum of all numbers from 1 to that number.
- Write a shell script that checks whether a given string is a palindrome or not.
- Write a shell script that finds and displays all the files in a directory that have a specific extension (e.g., ".txt").
- Write a shell script that displays the size of the largest file in a directory.
- Write a shell script that prompts the user to enter a directory name and recursively lists all files and subdirectories in that directory.
- Write a shell script that takes a sentence as input and displays the number of vowels and consonants in the sentence.
- Write a shell script that prompts the user to enter a directory name and recursively deletes all empty subdirectories in that directory.
- Write a shell script that takes a file name as input and counts the number of words, lines, and characters in that file.
- 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.
- 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.
- Write a shell script that finds and displays the top 5 largest files in a directory and its subdirectories.
- 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.
- Write a shell script that takes a file name as input and replaces all occurrences of a given word with another word.
- Write a shell script that monitors a log file in real-time and displays new lines as they are added to the file.
- 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.
- Write a shell script that prompts the user to enter a directory name and finds all duplicate files (based on content) within that directory.
- 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.
- 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.
- 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.
xdg-open "$(ls -t | head -n1)"uname -s
uname -n
uname -r
uname -v
uname -m
uname -i
cat /etc/os-release | grep "PRETTY_NAME"tac filename.txtdate +'%d/%m/%y'date +'%d-%m-%y/%H.%M.%S'cp ~/Desktop/file.txt ~/Documents/mkdir ~/Pictures/My\ Photosgrep "credit" memo.txtcat file1.txt file2.txt > combined.txtsort file.txt | uniq > newfile.txtsort -r data.txtgrep "the" myfile.txtls -lt --time=atimerm -r examplenl filename.txtmkdir ~/tempip link showDevelop 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.
Create a simple menu-driven interface that presents users with options for file and directory management tasks. 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. 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. 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. 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. Simple Input Validation: Validate user inputs to ensure they are not empty or contain invalid characters. Help Option: Include a help option that displays a brief description of the script's functionality and usage instructions.