We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. Prepare
  2. Linux Shell
  3. Text Processing
  4. Head of a Text File #1
  5. Tutorial

Head of a Text File #1

Problem
Submissions
Leaderboard
Discussions
Tutorial

Here's a useful video on the topic:

By default, it displays the first lines when used in the following form:

head [filename]
head -n 11 [filename]  -> First 11 lines  
head -c 20 [filename]  -> First 20 characters  

Since we will provide the text files via STDIN, the filename may be ignored.

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. Click here for more details about using the head command.

View Practice Challenge

tutorial details


Need Help?


View discussions
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy