Write down the regular expression for following questions 11) Valid URL beginnin
ID: 3667449 • Letter: W
Question
Write down the regular expression for following questions
11) Valid URL beginning with “https://”. (e.g. https://www.google.com)
12) GSU panther # in the format of 999-99-999. (e.g. 002-02-2222)
13) Valid IP address (IPv4) (4 numbers separated by “.”, the range of each number is 0-255) (e,g, 192.168.1.101)
14) Valid email address, assuming ‘a-z’,’0-9’,’-’,’_’, and ’.’ are valid characters for user id.
Part B
: File Processing The following table is from Wikipedia. It shows the eleven highest mountains in Georgia. In above table, each line contains 5 fields separated by comma. Create a file named “mountainList.txt” in your computer, and copy the contents in above table.
Or, you can download this file by using following command: wget http://grid.cs.gsu.edu/~bli6/teaching/spring2016/mountainList.txt Write down the command you would use for the following tasks.
15) Use grep to output the mountains with “ridge high point”.
16) Use egrep to output the mountains which is a “bald” or “knob”.
17) Use awk to convert the value of height from feet to meter and provide a line number for each line (e.g. Rabun Bald,(summit),1431.34,meter,Rabun County). The result should be stored in “newMountainList.txt”
18) Use sed to delete the second field (including the ‘,’ after it) in each line of “mountainList.txt”
19) Use awk to count the number of mountains belonging to each county. And output the result to “countyMountain.txt”. The format of result should be: County Name Number of Mountains (e.g. Union County 5) (hint: Wolfpen Ridge belongs to both Town and Union County )
20) Sort “countyMountain.txt” according to the number of mountains in descending order and output first two counties with more mountains.
Explanation / Answer
(1)$ grep ‘ridge high point’ mountainList.txt
(2) $ egrep 'Bald|Knob' mountainList.txt
(3) $awk -F, ‘{print NR, $1, $2, $3*0.3048, meters, $5}’mountainList.txt
(4) $sed -e’s/[(].*[)],//g' mountainList.txt
(5) $awk '/Union/{union=union+1;} /Towns/{towns=towns+1;}/Rabun/{rabun=rabun+1;} END{print "Union",union;print "Towns",towns;print "Rabun",rabun}' mountainList.txt > countyMountain.txt
(6) $ sort -nr +1 -2 countyMountain.txt
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.