Question

In: Computer Science

Write a script that accepts a single character argument (command line parameter), then checks to see...

Write a script that accepts a single character argument (command line parameter), then checks to see if the argument is an upper- or lower-case letter. (You do not have to do any error checking. Just assume that the user will enter a single character.) Hint: use grep to search for a member of the character class [a-z]. Then use the exit code (in an if statement) to see if grep was successful and write the proper response. If the argument is a letter, print (display to screen) “You entered a letter.” If the argument is not a letter, print “You did not enter a letter.”

Solutions

Expert Solution

letter.sh:

   #reads a command lone argument and checks for a upper-case or lower-case letter
   if grep -q "[a-zA-Z]" <<< "$1"
   #if block
   then
       #prints output if it is a letter
       echo "You entered a letter"
       #exit code for if statement
       exit 1
   #else block
   else
       #printf otput if the character is not a letter
       echo "You did not enter a letter"
   fi #end of if block

      

Output:


Related Solutions

A C program that accepts a single command line argument and converts it in to binary...
A C program that accepts a single command line argument and converts it in to binary with array length of 16 bits. The array should contain the binary of the int argument. the program should also convert negative numbers. Side note the command line arg is a valid signed int.
Write a Java application that accepts a bar code as a command line parameter and prints...
Write a Java application that accepts a bar code as a command line parameter and prints out the ZIP code. Assume that the bar code uses the symbols "|" and ":" for the long and short bars, respectively. Provide warnings on errors in the bar code specifying what exactly is wrong. The bar code input should be in the format specified in Problem 1, including the pair of the full bars at the beginning and at the end. Important: The...
Write a C program that accepts a port number as a command line argument, and starts...
Write a C program that accepts a port number as a command line argument, and starts an HTTP server. This server should constantly accept() connections, read requests of the form: GET /path HTTP/1.1\r\n\r\n read the file indicated by /path, and send it over the "connect" file descriptor returned by the call to accept().
Write a C program that accepts a port number as a command line argument, and starts...
Write a C program that accepts a port number as a command line argument, and starts an HTTP server. This server should constantly accept() connections, read requests of the form GET /path HTTP/1.1\r\n\r\n read the file indicated by /path, and send it over the "connect" file descriptor returned by the call to accept().
UNIX ONLY Write a bash script that will accept a filename as a command line argument....
UNIX ONLY Write a bash script that will accept a filename as a command line argument. Your script should first check whether the filename has been passed as argument or not (hint: at least one argument has to be provided). If no argument has been provided your script should display appropriate message and exit. If a file name has been provided, your script should check if the file exists in the current directory and display the contents of the file....
Write a C Unix shell script called showperm that accepts two command line parameters. The first...
Write a C Unix shell script called showperm that accepts two command line parameters. The first parameter should be an option flag, either r, w or x. The second parameter should be a file name. The script should indicate if the specified file access mode is turned on for the specified file, but it should display an error message if the file is not found. For example, if the user enters: showperm r thisfile the script should display “readable” or...
The program should be able to do the following: In Java accepts one command line parameter....
The program should be able to do the following: In Java accepts one command line parameter. The parameter specifies the path to a text file containing the integers to be sorted. The structure of the file is as follows: There will be multiple lines in the file (number of lines unknown). Each line will contain multiple integers, separated by a single whitespace. reads the integers from the text file in part a into an array of integers. sort the integers...
The Java program should be able to do the following: accepts one command line parameter. The...
The Java program should be able to do the following: accepts one command line parameter. The parameter specifies the path to a text file containing the integers to be sorted. The structure of the file is as follows: There will be multiple lines in the file (number of lines unknown). Each line will contain multiple integers, separated by a single whitespace. reads the integers from the text file in part a into an array of integers. sort the integers in...
Write a value returning function called isPrime. This function accepts integer number as parameter and checks...
Write a value returning function called isPrime. This function accepts integer number as parameter and checks whether it is prime or not. If the number is prime the function returns true. Otherwise, function returns false. A prime number is the number that can be divided by itself and 1 without any reminder, i.e. divisible by itself and 1 only. DO THIS USING C++ LANGUAGE .WITH UPTO CHAPTERS 5 (LOOP).
#1: Write a program that optionally accepts an address and a port from the command line....
#1: Write a program that optionally accepts an address and a port from the command line. If there is no address/port on the command line, it should create a TCP socket and print the address (i.e. server mode). If there is an address/port, it should connect to it (i.e. client mode). Once the connections are set up, each side should enter a loop of receive, print what it received, then send a message. The message should be “ping” from the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT