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
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. Linux Shell
  3. Text Processing
  4. Cut #5
  5. Discussions

Cut #5

Problem
Submissions
Leaderboard
Discussions
Editorial
Tutorial

Sort 119 Discussions, By:

votes

Please Login in order to post a comment

  • bruno_vercelli
    2 years ago+ 2 comments
    echo $line | cut -f1-3
    
    echo "$line" | cut -f1-3
    

    Why just the second one works? Which changes the double quotes causes?

    11|
    Permalink
  • mona87
    6 years ago+ 2 comments

    cut -d $'\t' -f1-3 worked for me. -d only takes only one character so cut -d ' ' -f1-3 wouldn't work. also cut -d "\t" -f1-3 wouldn't work.

    9|
    Permalink
  • mirnes_omerkic
    2 years ago+ 5 comments
    #!/usr/bin/env bash
    
    IFS=""
    while read line; do
      echo -e "$line" | cut -f -3
    done
    
    8|
    Permalink
    View more Comments..
  • general_bison
    5 years ago+ 5 comments

    I think this challenge is broken, the input doesn't seem to be tab seperated. EDIT: Seems to be working now

    8|
    Permalink
    View more Comments..
  • prajjwals12th
    2 years ago+ 3 comments

    This works

    #!/bin/bash
    while read s
    do
        echo "$s" | cut -f1-3
    done
    
    4|
    Permalink
Load more conversations

Need Help?


View tutorial
View editorial
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature