Thamizhiniyan C S
HomeWriteupsResourcesCheatsheets
HackerRank
HackerRank
  • HackerRank
  • Linux Shell
    • Bash
    • Text Processing
      • Cut
      • Head
      • Middle
      • Tail
      • Tr
      • Sort
      • Uniq
      • Paste
    • Arrays In Bash
    • Grep Sed Awk
      • Grep
      • Sed
      • Awk
  • Regex
    • Introduction
    • Character Class
    • Repetitions
    • Grouping and Capturing
    • Backreferences
    • Assertions
    • Applications
  • Python
    • Introduction
    • Basic Data Types
    • Strings
    • Sets
    • Math
    • Itertools
    • Collections
    • Date and Time
    • Errors and Exceptions
    • Classes
    • Built-Ins
    • Python Functionals
    • Regex and Parsing
    • XML
    • Closures and Decorators
    • Numpy
    • Debugging
  • C
    • Introduction
    • Conditionals and Loops
    • Arrays and Strings
Powered by GitBook
On this page
  • Cut #1
  • Cut #2
  • Cut #3
  • Cut #4
  • Cut #5
  • Cut #6
  • Cut #7
  • Cut #8
  • Cut #9

Was this helpful?

  1. Linux Shell
  2. Text Processing

Cut

Cut #1

Given N lines of input, print the 3rd character from each line as a new line of output. It is guaranteed that each of the lines of input will have a 3rd character.

cut -c 3

Cut #2

Display the 2nd and 7th character from each line of text.

cut -c 2,7

Cut #3

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

cut -c 2-7

Cut #4

Display the first four characters from each line of text.

cut -c -4

Cut #5

Given a tab delimited file with several columns (tsv format) print the first three fields.

cut -f -3

Cut #6

Print the characters from thirteenth position to the end.

cut -c 13-

Cut #7

Given a sentence, identify and display its fourth word. Assume that the space (' ') is the only delimiter between words.

cut -d ' ' -f 4

Cut #8

Given a sentence, identify and display its first three words. Assume that the space (' ') is the only delimiter between words.

cut -d ' ' -f -3

Cut #9

Given a tab delimited file with several columns (tsv format) print the fields from second fields to last field.

cut -f 2-
PreviousText ProcessingNextHead

Last updated 1 year ago

Was this helpful?