Head of a Text File #2 HackerRank Solution

Hello coders, In this post, you will learn how to solve Head of a Text File #2 HackerRank Solution. This problem is a part of the Linux Shell series.

Head of a Text File #2 HackerRank Solution
Head of a Text File #2 HackerRank Solution

Head of a Text File #2 HackerRank Solution

Problem

In this challenge, we practice using the head command to display the first n characters of a text file.

Display the first 20 characters of an input file.

Input Format

A text file.

Output Format

Output the first 20 characters of the text file.

Sample Input

New York is a state in the Northeastern and Mid-Atlantic regions of the United States.
New York is the 27th-most extensive, the third-most populous populated of the 50 United States.
New York is bordered by New Jersey and Pennsylvania to the south.
About one third of all the battles of the Revolutionary War took place in New York.
Henry Hudson’s 1609 voyage marked the beginning of European involvement with the area.

Sample Output
New York is a state

Head of a Text File #2 HackerRank Solution

#Output the first 20 characters of the text file
head -c 20

Note: This problem (Head of a Text File #2) is generated by HackerRank but the solution is provided by chase2learn. This tutorial is only for Learning and Educational purpose. Head of a Text File #2 HackerRank Solution.

Sharing Is Caring