Raymond2688
New Member
Good morning everyone,
I am new to the forum and very new to Linux. I am currently taking an intro to Linux class, and I can't believe how hard this class is. I would never have thought I would be close to failing an intro class, but it is what it is. I came to this forum to see if I can get some help. I have been days on this one string I have to create. I am hoping that maybe you guys can help me out. Now, this is basic stuff, so I don't know why I can't get the hang of it, but here it goes. Below is the lab
Step 1 Use 'sed' to remove all punctuation from usdeclar.txt, which would be a comma, colon, semicolon and period
· Use 'sed' to remove all blank lines
· In other words, you will run 'sed '<expr>' usdeclar.txt' to remove a particular character. NOTE: There are ways to remove multiple characters, but do not do so.
· Review the slides or text book to find the correct subsitution <expr> to use.
· Or search the Internet to find the correct substitution <expr> to use for each particular character. For example, search for "how to remove …. using sed"
Step 1a – remove commas
· If you use the correct <expr>, the following should not return any results
sed '<expr>' usdeclar.txt | grep ','
Step 1b – remove colonssed
· If you use the correct <expr>, the following should not return any results
sed '<expr>' usdeclar.txt | grep ':'
Step 1c – remove semicolons
· If you use the correct <expr>, the following should not return any results
sed '<expr>' usdeclar.txt | grep ';'
Step 1e – remove periods sed '/^$/d' /tmp/data.txt > /tmp/output.txt
· If you use the correct <expr>, the following should not return any results
sed '<expr>' usdeclar.txt | grep '\.'NOTE: For grep, the period is escaped by the backward slash
Step 1f – remove blank lines -e '/^[[:space:]]*$/d'
· If you use the correct <expr>, the following should not show any blank lines
sed '<expr>' usdeclar.txt | head
Step 1g – chain the commands
· Chain all of these 'sed' commands together using the pipe operation and rediect the output to sed_edits.txt
· The command chain should look like
sed '<expr>' usdeclar.txt | sed '<expr>' | sed '<expr>' | sed '<expr>' | sed '<expr>' > sed_edits.txt
NOTE: The 'sed' order be for removing commas, colons, semicolons, periods and blank line
This QUESTION is worth 20 points. Write your answer in the box.
What is the command chain you will run?
sed 's/,//g' usdeclar.txt | sed 's/://g' | sed 's/;//g' | sed 's/-//g' | sed 's/&//g' | sed 's/\.//g' | sed 's/ / /g' | sed '/^$/d' > sed_edits.txt (this is what I came up with) my word count is wrong
· Run 'clear'
· Run the command chain you entered in the box
· Run 'head sed_edits.txt'
· Run 'wc sed_edits.txt' to get the line, word and byte count of sed_edits.txt
· Run 'grep ',' sed_edits.txt | grep ':' | grep ';' | grep '\.'
NOTE: The 'grep' order should be for commas, colons, semicolons and periods
· Run 'date'
I am new to the forum and very new to Linux. I am currently taking an intro to Linux class, and I can't believe how hard this class is. I would never have thought I would be close to failing an intro class, but it is what it is. I came to this forum to see if I can get some help. I have been days on this one string I have to create. I am hoping that maybe you guys can help me out. Now, this is basic stuff, so I don't know why I can't get the hang of it, but here it goes. Below is the lab
Step 1 Use 'sed' to remove all punctuation from usdeclar.txt, which would be a comma, colon, semicolon and period
· Use 'sed' to remove all blank lines
· In other words, you will run 'sed '<expr>' usdeclar.txt' to remove a particular character. NOTE: There are ways to remove multiple characters, but do not do so.
· Review the slides or text book to find the correct subsitution <expr> to use.
· Or search the Internet to find the correct substitution <expr> to use for each particular character. For example, search for "how to remove …. using sed"
Step 1a – remove commas
· If you use the correct <expr>, the following should not return any results
sed '<expr>' usdeclar.txt | grep ','
Step 1b – remove colonssed
· If you use the correct <expr>, the following should not return any results
sed '<expr>' usdeclar.txt | grep ':'
Step 1c – remove semicolons
· If you use the correct <expr>, the following should not return any results
sed '<expr>' usdeclar.txt | grep ';'
Step 1e – remove periods sed '/^$/d' /tmp/data.txt > /tmp/output.txt
· If you use the correct <expr>, the following should not return any results
sed '<expr>' usdeclar.txt | grep '\.'NOTE: For grep, the period is escaped by the backward slash
Step 1f – remove blank lines -e '/^[[:space:]]*$/d'
· If you use the correct <expr>, the following should not show any blank lines
sed '<expr>' usdeclar.txt | head
Step 1g – chain the commands
· Chain all of these 'sed' commands together using the pipe operation and rediect the output to sed_edits.txt
· The command chain should look like
sed '<expr>' usdeclar.txt | sed '<expr>' | sed '<expr>' | sed '<expr>' | sed '<expr>' > sed_edits.txt
NOTE: The 'sed' order be for removing commas, colons, semicolons, periods and blank line
This QUESTION is worth 20 points. Write your answer in the box.
What is the command chain you will run?
sed 's/,//g' usdeclar.txt | sed 's/://g' | sed 's/;//g' | sed 's/-//g' | sed 's/&//g' | sed 's/\.//g' | sed 's/ / /g' | sed '/^$/d' > sed_edits.txt (this is what I came up with) my word count is wrong
· Run 'clear'
· Run the command chain you entered in the box
· Run 'head sed_edits.txt'
· Run 'wc sed_edits.txt' to get the line, word and byte count of sed_edits.txt
· Run 'grep ',' sed_edits.txt | grep ':' | grep ';' | grep '\.'
NOTE: The 'grep' order should be for commas, colons, semicolons and periods
· Run 'date'