Hello, can anyone help me on this question and answer it all for me? I\'m quite
ID: 3788426 • Letter: H
Question
Hello, can anyone help me on this question and answer it all for me? I'm quite struggling and don't know what to do here your help will be a life saver and i appreciate it. thank you!
Assignment 4 questions and inputs:
write egrep commands to match all lines that contain the letter a and b(either upper or lower case) and all lines that conatin the word a(either upper or lower case) followed by a word starting with a vowel and test it on the given input.
Assignment 4 input test:
a apple
A elephant
a banana
zero
yellow yaks
zippy zebras
Assignment 5 questions and input:
edit the regex [0-9]?[0-9]:[0-9][0-9](am|pm) so it doesn't match illegal time like 99:99pm
Assignment 5 test input: use the egrep command to teest it on the inputs
10:31am
9:30pm
9:30
9:3am
99:99pm
Assignment 6:
print "Enter a temperature (i.e. 32F, 100C): ";
$input = ; # this will read one line from the user
chop($input); # this removes the ending newline from $input
if ($input =~ m/^([-+]?[0.-9]+)([Cc|fF])$/)
{
# If we get in here, we had a match.
# $1 is the number and $2 is "C" or "F"
$InputNum = $1; # save to named variables to make easier to read
$type = $2;
$space = " ";
if ($type eq "C") {
$celsius = $InputNum;
$fahrenheit = ($celsius * 9 / 5) + 32;
}
else {
$fahrenheit = $InputNum;
$celsius = ($fahrenheit - 32) * 5 / 9;
}
printf "%.2f C = %.2f F ", $celsius, $fahrenheit;
}
else {
print "Expecting a number, so don't understand "$input". ";
}
Explanation / Answer
Assignment 2:
b)
^a*(bbb)*
c)
(bab)*
Assignment 4:
a)All lines that contain letter a and b (either Upper or lower)
egrep "*[abAB]*" filename
note: here filename can be any path or name of a file
as given in question 4 filename will be jillz/cs250/lab3/testfile1
b)All lines that contains the word a and followed by word starting with vowel
egrep "^[aA] [aeiou]*" filename
Assignment 5:
edit the regex [0-9]?[0-9]:[0-9][0-9](am|pm) so it doesn't match illegal time like 99:99pm
egrep "[0-1]?[0-2]:[0-5][0-9](am|pm)"jillz/cs250/lab3/testfile1
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.