1. Using regular expressions with \'grep\' Download the GNU GPL License file fro
ID: 3890980 • Letter: 1
Question
1. Using regular expressions with 'grep'
Download the GNU GPL License file from: https://www.gnu.org/licenses/gpl-2.0.txt
Display the lines of that start with any Uppercase letter or a number. Then count the number of lines that end with the either a period, comma or semicolon.
Count the number of times the word free appears within the file then count the number of words that contain the word free.
Count the number of words that have a length of 8 and 12 characters long
2. File parsing with 'awk'
Download the csv from: http://archive.ics.uci.edu/ml/machine-learning-databases/00267/data_banknote_authentication.txt
Compute the average of the first four columns.
In the last column count the number occurrences of either 1 or 0.
I've never done scripting before and my professor is expecting us to learn how to script for our labs. Any help would be really appreciated
Explanation / Answer
Hi,
I could complete answer 1 only for the time allocated.
Ans 1-
a) Display the lines of that start with any Uppercase letter or a number.
sed -n '/^[A-Z0-9]/p'
b) Then count the number of lines that end with the either a period, comma or semicolon.
sed -n '/(;|.|,)+$/p'
c) Count the number of times the word free appears within the file then count the number of words that contain the word free
grep -o 'free' filename | wc -l
d) Count the number of words that have a length of 8 and 12 characters long
awk 'length($1) ==4 { print $1 }'
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.