Skip to content
Programming101
Programming101

Learn everything about programming

  • Home
  • CS Subjects
    • IoT – Internet of Things
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programming101
Programming101

Learn everything about programming

HackerRank Tail of a Text File #2 problem solution

YASH PAL, 31 July 2024

In this HackerRank Tail of a Text File #2 problem solution In this challenge, we practice using the tail command to display the last n characters of a text file.

Display the last 20 characters of an input file.

Input Format

A text file.

Output Format

Output the last 20 characters of the text file.

HackerRank Tail of a Text File #2 problem solution

Problem solution.

touch file
cat > file
tail -c 20 file

Second solution.

read lines
while read line; do
    lines=$lines$'n'$line
done
echo "$lines" | tail -c 20

Third solution.

tail -c 20

coding problems linux shell

Post navigation

Previous post
Next post
  • HackerRank Separate the Numbers solution
  • How AI Is Revolutionizing Personalized Learning in Schools
  • GTA 5 is the Game of the Year for 2024 and 2025
  • Hackerrank Day 5 loops 30 days of code solution
  • Hackerrank Day 6 Lets Review 30 days of code solution
©2025 Programming101 | WordPress Theme by SuperbThemes