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.
paste -sd ' ' This command takes input from standard input and concatenates all the lines together using spaces to separate them. The -s option tells paste to join all the lines from input together and the -d option specifies the delimiter (in this case a space). The result is a single line of output with all the lines from the input glued together with spaces.
cut -d' ' -f4-8 This command takes the output from paste and splits it into fields using spaces as the delimiter. The -d option tells cut to use a space as the field delimiter. The -f option specifies which fields to keep. In this case, -f4-8 tells cut to keep fields 4 through 8 (inclusive). So, the final output will contain only the 4th through 8th words in the input.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Slice an Array
You are viewing a single comment's thread. Return to all comments →
paste -sd ' '
This command takes input from standard input and concatenates all the lines together using spaces to separate them. The-s
option tells paste to join all the lines frominput
together and the-d
option specifies the delimiter (in this case a space). The result is a single line of output with all the lines from the input glued together with spaces.cut -d' ' -f4-8
This command takes the output from paste and splits it into fields using spaces as the delimiter. The-d
option tells cut to use a space as the field delimiter. The-f
option specifies which fields to keep. In this case,-f4-8
tells cut to keep fields4
through8
(inclusive). So, the final output will contain only the 4th through 8th words in the input.