Write a shell script which takes input of file name and prints first 10 lines of that file. file name is to be passed as command line argument. If argument is not passed then any „C‟ program from the current directory is to be selected.

Write a shell script which takes input of file name and prints first 10 lines of that file. file name is to be passed as command line argument. If argument is not passed then any „C‟ program from the current directory is to be selected. SOLUTION…. #!/bin/bash # Script to print first 10 lines of […]

Write a shell script to prompts the user to enter the time (in 24-hour format) then wish them “Good morning”, “Good afternoon”, “Good evening”, or “Good night” based on the input. (example: If Input is 13 then print Good afternoon)

Write a shell script to prompts the user to enter the time (in 24-hour format) then wish them “Good morning”, “Good afternoon”, “Good evening”, or “Good night” based on the input. (example: If Input is 13 then print Good afternoon) SOLUTION…. #!/bin/bash # Script to greet user based on time input echo “Enter the time […]

Write a script to delete all vowels from particular string

Write a script to delete all vowels from particular string SOLUTION…. #!/bin/bash # Script to delete all vowels from a given string echo “Enter a string:” read str # Remove vowels using sed (both lowercase and uppercase) result=$(echo “$str” | sed ‘s/[aeiouAEIOU]//g’) echo “String without vowels: $result” OUTPUT

Write a script which enters username s& password & check that if the username = sugc& password=98765 then display the valid user message. Otherwise invalid user.

Write a script which enters username s& password & check that if the username = sugc& password=98765 then display the valid user message. Otherwise invalid user. SOLUTION…. #!/bin/bash # Script to check username & password with max 3 attempts correct_user=”sugc” correct_pass=”98765″ attempt=1 max_attempts=3 while [ $attempt -le $max_attempts ] do echo “Attempt $attempt of $max_attempts” […]