Skip to content
Programmingoneonone
Programmingoneonone
  • Engineering Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
    • 100+ C++ Programs
  • Solutions
    • HackerRank
      • Algorithms Solutions
      • C solutions
      • C++ solutions
      • Java solutions
      • Python solutions
    • Leetcode Solutions
    • HackerEarth Solutions
  • Work with US
Programmingoneonone
Programmingoneonone

HackerRank Cut #3 problem solution

YASH PAL, 31 July 20246 February 2026

In this HackerRank Cut #3 problem-solution Using cut, multiple items can be retrieved with the same command. For instance, to return multiple columns from a line, there are two basic needs:

  1. Multiple columns that are not contiguous
  2. Multiple columns that are contiguous

The following commands split a string on dots, then return columns 1 and 3, then columns 1 through 3. The -d flag specifies the delimiter and the -f flag specifies the column(s) to return. Note that the delimiter is added back in to the results.

echo 100.200.300.400 |cut -d ‘.’ -f 1,3

100.300

echo 100.200.300.400 |cut -d ‘.’ -f 1-3

100.200.300

Read the man pages for concise documentation.

Display a range of characters starting at the 2nd position of a string and ending at the 7th position (both positions included).

HackerRank Cut #3 problem-solution

Problem solution.

#!/bin/bash
while read line; do
  if [[ $line == "" ]]; then
    break;
  else
    echo $line | cut -c2-7
  fi
done

Second solution.

cut -c2-7

Third solution.

cut -c2-7 $1

coding problems solutions Hackerrank Problems Solutions linux shell HackerRankLinux shell

Post navigation

Previous post
Next post

Programmingoneonone

We at Programmingoneonone, also known as Programming101 is a learning hub of programming and other related stuff. We provide free learning tutorials/articles related to programming and other technical stuff to people who are eager to learn about it.

Pages

  • About US
  • Contact US
  • Privacy Policy

Practice

  • Java
  • C++
  • C

Follow US

  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2026 Programmingoneonone | WordPress Theme by SuperbThemes