Linux Contest with a $25 Amazon Gift Card Giveaway – Week 4

It’s again time for the fourth and final question in the $25 Amazon Gift Card Giveaway. apokalyptik, Ben P., Mahmoud, and Olivers won week 3 by answering our question most accurately.  To recap, every week we are asking a Linux question.  We want readers to post their answer in the comments section at the bottom of the post.  At the end of this week the person who has answered the most questions correctly will win a $25 Amazon Gift card.  If there are four different winners each week, a winner within the winners will be chosen at random.  If there is a tie, the winner will be determined based on who posted their answers the fastest.  Go here for the complete rules.

Question 4 : Week 4

From the command line, how do you remove all the blank lines from example_file1 and output the results into example_file2?  Note, you want to preserve example_file1.

The most complete and straightforward answer will win!

Post your answers at the bottom of this post in the comments!

Remember, subscribe to the RSS feed to get notified of the answer.  To prevent copying of answers, you will not see any comments until the end of the week.

8 thoughts on “Linux Contest with a $25 Amazon Gift Card Giveaway – Week 4

  1. Apart from an awk script to do the same, i prefer writing one line of bash to do the trick.

    input: example_file_1
    output: example_file_2

    cat example_file_1|while read line;do if [ "$line" != "" ]; then echo "$line"; fi; done>example_file_w

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>