Question 3: grep In this question, use the grep command to return all words that
ID: 3589068 • Letter: Q
Question
Question 3: grep In this question, use the grep command to return all words that are either 5 or 6 letters in length in the file /home/data_scientist/w6p1/wordsEn.txt. Pipe the results to the file q3.txt located in folder: /home/data_scientist/w6p1. Make sure to also account for the null character. In [ ] : %%bash # YOUR CODE HERE In 1ist_dir -1s /home/data_scientist/wop1/ assert_true ('q3.txt' in list dir, msg-'Did you pipe the results to the correct path? You might want to use an absolute acc_words cat /home/data_scientist/w6p1/q3.txt assert_true ('aahed' in '"-join(acc_words) ) assert_true ('abbrev' in'.join (acc_words),msg-'abbrev is not in your results. Did you count the null character at the In [ ] : %%bash RUN THIS COMAND TO CLEAN UP THE TEST DIRECTORY rm -rf w6p1Explanation / Answer
The following command will count and return all the words that are either 5 or 6 letters length in a file.
>grep -o -w 'w{5,6}' /home/data_scientist/w6p1/wordsEn.txt > /home/data_scientist/w6p1/q3.txt
will redirect the output to the file q3.txt.
The options -o, and -w means print only the matching parts, and the words of length 5, and 6 respectively.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.