Write a function called rightmatch that takes two arguments as shown:

rightmatch value pattern

where value is a sequence of one or more characters, and pattern is a shell pattern that is to be removed from the right side of value. The shortest matching pattern should be removed from value and the result written to standard output. Here is some sample output:
$ rightmatch test.c .c
test
$ rightmatch /usr/spool/uucppublic '/*'
/usr/spool
$ rightmatch /usr/spool/uucppublic o
/usr/spool/uucppublic
$
The last example shows that the rightmatch function should simply echo its first argument if it does not end with the specified patter


# rightmatch value pattern

# remove shortest matching pattern from value
# accomplished with ${var%patt}

value=$1
pattern=$2

echo ${value%$pattern}

Computer Science & Information Technology

You might also like to view...

Define jump rules and explain how they work.

What will be an ideal response?

Computer Science & Information Technology

Design view of a table shows the data contents within a table

Indicate whether the statement is true or false

Computer Science & Information Technology

? A message can be queued, or temporarily held with other messages.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

Answer the following questions true (T) or false (F)

1. A function that takes no arguments is more versatile than a function that requires arguments. 2. A function must be defined before it can be referenced. 3. A function prototype specified the function operation.

Computer Science & Information Technology