Display the lines which are starting with 1 at the beginning.
Display the lines which are starting with 1 at the beginning. SOLUTION….
Display the lines that do not contain “Unix”.
Display the lines that do not contain “Unix”. SOLUTION….
To list file names consist of only 4 digits.
To list file names consist of only 4 digits. SOLUTION….
Display all blank lines between line 20 and 30 of file test.txt.
Display all blank lines between line 20 and 30 of file test.txt. SOLUTION….
Write a command to replace „RAM‟ with „ROM‟ on line no 10 to 20.
Write a command to replace „RAM‟ with „ROM‟ on line no 10 to 20. SOLUTION….
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 Check whether file is empty or not, And if file name doesn‟t exist than print appropriate message.
Write a script to Check whether file is empty or not, And if file name doesn‟t exist than print appropriate message. SOLUTION…. #!/bin/bash # Script to check whether file is empty or not echo “Enter file name:” read fname if [ -e “$fname” ]; then if [ -s “$fname” ]; then echo “✅ File ‘$fname’ […]
Write a script to accept a number from user until he enters 0 & find sum of all that numbers.
Write a script to accept a number from user until he enters 0 & find sum of all that numbers. SOLUTION…. #!/bin/bash # Script to find sum of numbers until user enters 0 sum=0 echo “Enter numbers (enter 0 to stop):” while true do read num if [ $num -eq 0 ]; then break fi […]
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
