We highly recommend downloading the files for this Q&A and following along with us:
wget https://courses.cs.washington.edu/courses/cse391/21sp/lectures/7/questions7.zip unzip questions7.zip
Suppose that we have the following file called
emails.txt, where each line contains a list of a person’s emails:What is the command to print the contents of the file such that all of the
email@example.com, firstname.lastname@example.org email@example.com firstname.lastname@example.org
@symbols are replaced with
at(there should be spaces on either side), The output should look like:
scot at uw.edu, scot at cs.washington.edu may at tech-company.com ning at nonprofit.ngo
The following file,
poem.txt, is a short poem which has been poorly formatted:Write a command that outputs
I see you driving round town with the one I love and I'm like haiku
poem.txtsuch that there is only a single space between each word.
One of the new developers at faang introduced a bug into the source code that incorrectly logged ticket id’s for product transactions. The contents of
log.txtare as follows:The problem is that the first four characters should actually appear at the end of the line. Write a command that has the corrected ticket id’s (i.e.)
The following file,
secret.txtcontains a conversation between two spies.Our goal is to replace all lines of the conversation that contain the word
Spy 1: I heard that you like secret kit kats Spy 2: Indeed. I saw Person X eating one the other day. Spy 1: Did you drop off the secret m&ms? Spy 2: No, I ate them. Spy 1: ... Spy 2: Keep that a secret.
secretwith REDACTED. Our output should look like:
REDACTED Spy 2: Indeed. I saw Person X eating one the other day. REDACTED Spy 2: No, I ate them. Spy 1: ... REDACTED
Write a command that converts 7 letter palindromes into two words, such that the 4th character is replaced with a space and the last three characters are reversed. For example, if we ranThe output would be
echo "racecar" | YOUR_COMMANDChallenge: Can you write a similar command which has the same behavior, but prints nothing if the input string is not a 7-character palindrome?