It's UWAweek 48

help2003/help4407

This forum is provided to promote discussion amongst students enrolled in Open Source Tools and Scripting.

Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!"  followup message.

How do I ask a good question?
Displaying selected article
Showing 1 of 564 articles.
Currently 3 other people reading this forum.


 UWA week 16 (1st semester, non-teaching week) ↓
SVG not supported

Login to reply

👍?
helpful
5:51pm Mon 18th Apr, Peter M.

"Ryan Bunney" [email protected] wrote:

Hi Peter,

As we've discussed in the labs, there are multiple ways to 'skin the Unix cat', so it is entirely possible you have completed the assignment conditions without sed.

The reason that I advocate (in this particular instance) for the use of sed over tail can be tested locally at your end:

  • Currently, the presence of the U+EFF/BOM at the beginning of the file leads to your method producing a list of words, with the first line being empty (likely, the result of the BOM).
  • If you were to be given a file without the BOM (or you use the sed technique above to remove it if it exists, or you create your own test file), does this still produce an empty line at the top of the list of words?
  • If it does not produce that empty line, then the use of tail +2 (a la. the labs with the CSV headers) is going to affect your results, as you will be skipping a word, rather than an empty line.

I should note that when I mention the use of sed, I am not suggesting permanently editing the files in-place - rather, as is the case in various pre-processing scenarios, I can create an intermediary file (maybe $FILENAME.edit), do my operations on that, and then remove that edited file once the analysis has been done.

I hope that clarifies things.

Warm Regards,

Ryan.

Hi Ryan,

When I remove the BOM, my method no longer produces the empty line. I now see your point about using tail.

Thanks,

Peter.

The University of Western Australia

Computer Science and Software Engineering

CRICOS Code: 00126G
Written by [email protected]
Powered by history
Feedback always welcome - it makes our software better!
Last modified  1:17AM Sep 14 2022
Privacy policy