1.Write a shell script function called reversal that displays the reverse of a given string.
2.Write a shell script function that changes a given string to all CAPS.
Answer 1): HomeworkLib.sh (filename)
#!/bin/bash
reversal()
{
#read the input from commandline and store in input variable
read -p "Please enter the input string:" input
#finding the length of input string and store in
len_of_string
len_of_string=${#input}
#run a for loop for entire length and print each character from
last to first and append in output string variable each time
for (( i=$len_of_string-1; i>=0; i-- ))
do
output="$output${input:$i:1}"
done
#print the output
echo "Reverse of given input string is : $output"
}
#script starts here
#calling the reversal function
reversal
OUTPUT:
[root@njangid ~]# ./HomeworkLib.sh
Please enter the input string:Nicklodean
Reverse of given input string is : naedolkciN
==================================================================
Solution 2):
#!/bin/bash
ConvertToUpperCase()
{
#read the input from commandline and store in input variable
read -p "Please enter the input string : " input
echo "After converting in into Capital letters given input string
is : "
echo $input | tr '[a-z]' '[A-Z]'
}
#script starts here
#calling the function
ConvertToUpperCase
OUTPUT: HomeworkLib.sh(filename)
[root@Navin ~]# ./HomeworkLib.sh
Please enter the input string:Hello
After converting in into Capital letters given input string is
:
HELLO
1.Write a shell script function called reversal that displays the reverse of a given string. 2.Write...
[10 marks] Write a recursive method, reverse, that displays a string in a reverse order. For example, reverse("UBC-O") displays O-CBU. Use a helper method to improve the performance of your program. Write a test program that prompts the user to enter a string and displays its reversal. MUST HAVE A HELPER METHOD TO IMPROVE PERFORMANCE. FOR JAVA THANK YOU!
Write a C shell script called canrun that displays the names of the files in the current directory that have execute permission set (permission being for the file owner) and how many of these files there are. For example, output from the script might look like: Executable files: canrun menunix showperm 3 files found
Programs/scripts 13. Write a bash shell script that displays the date by using the shell command date. 14. Write a command line program that takes a number and a command as arguments. Call that command that number of times. For example, if your program name is "test" test 3 dir <shows directory> dir <shows directory> dir <shows directory>
LINUX question Write a shell script called findcapital to find the capital of a state, given the state. Create a function called read_state that reads your capitals file into an array. Create another function called find_it that checks if the user's inputted state matches one of the elements in the array. It matches, tell the user the capital. The main part of the program will execute the read_states function, get the input, then execute the find_it function. Add the following...
Write a program that accepts a String value from the user and displays the reverse of that value. For additional challenge, determine if the String and its reverse are equal and display a message explaining the result.
Write a bash shell script called direct.sh. This script will take an arbitrary number of command line arguments. Your script should create directories starting with the first argument, then the second directory inside the first one, and then the next one inside the second one, and so on.
1. Write a C shell script called greeting that asks the user how they are doing today. If the user enters anything other than “fine”, the script should ask the user again how they are doing. Eventually, when the user enters “fine” for their answer, the script should write out a message saying the computer is fine too. You will need to use a while loop
Python please Write a function print_back_upper() that accepts a string my_str as an argument and displays the string backwards and in uppercase, all in one line (Note: Create any necessary variables) For example: if my_str = "Python" then, your output should display as follows: NOHTYP (Hint: You can use for loop navigating up to range of len of string-1, -1, -1 and use reverse() and upper() functions to create and display the string backwards in uppercase)
Write a function (and main) that checks if a string (character array) is a reversal of itself, i.e., if the string is the same being read from the end. Argument: unsigned char str[]. Output value of type _Bool returning 1 (TRUE) or 0 (FALSE).
___________________ Create a shell script program that has displays the following menu on a page: This is a Linux Question, and the script is written in Vi test, and run in Putty. Press 1 to enter new order. Press 2 to access order status. Press 3 to cancel order. Paste a screenshot shot of the code below Paste a screenshot of the code output below (2 point):