Multiple choice technology operating systems

How to find the 51th record of a file containing 100 records in unix

  1. head -n 51 filename |tail -1

  2. head -51 <filename> |tail -1

  3. sed -n 51p <filename>

  4. All of the above

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

All three commands correctly display the 51st line. 'head -n 51 filename | tail -1' extracts first 51 lines then takes the last one. 'head -51 filename | tail -1' is shorthand for the same. 'sed -n 51p filename' uses sed to print only line 51. Each approach works: head/tail piping or sed direct addressing.