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.
'Sort' command #6
'Sort' command #6
Sort by
recency
|
29 Discussions
|
Please Login in order to post a comment
!/bin/bash
rm file.txt > stdout.txt 2> stderr.txt while IFS= read -r line || [ -n "line" >> file.txt done
-n sort numeric
-k column sort
-t seperator type
sort -n -k2 -t$'\t'< file.txt
-t$'\t': This option specifies that the field separator should be a tab character\t. The$'\t'syntax is a Bash feature that allows you to represent special characters, such as tabs, in a way that the shell can understand.-k2n: This option tellssortto sort the file based on the numeric value of the second column. The2specifies the column number, and thentells sort to sort the column numerically.I did not know about 3.1.2.4 ANSI-C Quoting so I wrote:
correct answer is `sort -t $'\t' -k2n
but
You can find here HackerRank Linux Shell Solutions
Sort Command #6 HackerRank Solution