Day 3.5 Exercise 17 More Files

Here’s my work.
Here’s the link to exercise 17.

Ex17 Code
Ex17 Code
Ex17 Output
Ex17 Output
Ex17a Single Lines
Methods on how to shorten the whole script into single line.

Study Drills

1. This script is really annoying. There’s no need to ask you before doing the copy, and it prints too much out to the screen. Try to make the script more friendly to use by removing features.
Done, See above.

2. See how short you can make the script. I could make this one line long.
Depends on how you define one line long, I’ve listed 3 methods to do so, I believe Zed hinted using first method. However, 3rd method is the true one line function.

3. Notice at the end of What You Should See I used something called cat? It’s an old command that “con*cat*enates” files together, but mostly it’s just an easy way to print a file to the screen. Type man cat to read about it.
Too much stuff to read?

4. Find out why you had to write out_file.close in the code.
I tried removing it from the code source, everything still works. According to some webpages, having too many files open can cause memory leaks, therefore it is good practice to close them.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s