In this HackerRank Cut #5 problem solution we have given a tab-delimited file with several columns (tsv format) print the first three fields.

Input Format

A tab-separated file with lines of ASCII text only.


1 <= N <= 100

2 <= C <= 100

(N is the number of lines of text in the input file and C is the number of columns of data in the file)

Output Format

The output should contain N lines. For each line in the input, print the first three fields.

HackerRank Cut #5 problem solution

Problem solution.

cut -f -3

Second solution.

while read line
cut -f-3 <<< "$line"

Third solution.

while read -r x
    echo "$x" | cut -f1-3
exit 0