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>
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)
___________________ 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):
Write a program to reverse an integer number by using a function called reverse. The program reads in an integer number and prints its reverse order. Note that the function receives the number via a pointer, and uses the pointer to write the reverse number on the main function. The function MUST be used AS IS: void reverse(int *n) Language in C Bonus Problem: Number Reverser reverse c Write a program to reverse an integer number by using a function...
in Linux, BASH Shell Write a while loop script called count that counts and prints the numbers 0 thru 9 without issuing a new line after each output.
Write a function in HASKELL to reverse a string (or list) without using the built-in reverse function. Example: Hello as olleh or [1,3,4,5] as [5,4,3,1].
Using C, Write a function reverse which takes a string as an argument, reverses the string and returns the reversed string. Note; you should not return a string that you created inside the reverse function! For example: Test char str[]-"hello" printf("%s", reverse (str)); Result olleh
Homework No.2 CSC 222 Write a shell script program called "countf.sh" that will count how many files or directories recursively. beside the file counts, also report how many files for each types (directory or regular files). It will either take arguments for specific directories and no argument. If no argument, it will read the current working directory as the starting point. Please also provide -h option to print out how to use your countf.sh program % ./countf.sh % ./countf.sh file1...