Printing a Single Line by Line Number with Sed

Well it turned out that I am not yet that comfortable in shell scripting. I often get error messages which indicating the line numbers on which a problem occurs and I wanted to print that single line of a given file. So I ended up with a solution which was built upon a combination of head and tail, before I finally realized that sed is the right tool for the job.

sed -ne 7p filename

Prints out line number 7 of filename, if you want some context which is likely then supply a range instead of a single line, which can be accomplished as follows.

sed -ne 5,10p filename

Marc