In this HackerRank Head of a Text File #1 problem solution In this challenge, we practice using the head command to display the first 20 lines of a text file.
Display the first 20 lines of an input file.
Input Format
A text file.
Output Format
Output the first 20 lines of the given text file.
We can also specify a certain number of lines to be displayed and list multiple filenames as well. It may also be used to display a specified number of bytes from an input file.
Problem solution.
#!/bin/bash file= 'cat /dev/stdin' head -20 $file
Second solution.
head -n 20
Third solution.
head -20