In the Unix sort command (historical POSIX/legacy syntax), which position option begins sorting after the nth column of the (m+1)th field?

Difficulty: Medium

Correct Answer: +(m+l).n

Explanation:


Introduction / Context:
Older Unix sort utilities (and some current implementations in legacy mode) support field/column specifications using the historical +m.n notation to set the starting key position. Understanding this syntax is valuable when you encounter classic scripts or exam questions referencing it, even though modern sort often prefers the -k option.


Given Data / Assumptions:

  • Legacy sort position syntax is being referenced.
  • You need to start sorting after the nth column of the (m+1)th field.
  • Fields are whitespace-delimited unless specified otherwise.


Concept / Approach:

In the historical format, +m.n indicates the sort key starts at field m+1, column n+1 within that field (semantics vary slightly by implementation, but exam convention treats it as “after nth column of (m+1)th field”). Therefore expressing “(m+1)th field and nth column” is commonly written as +(m+1).n. In the provided options, +(m+l).n uses l to indicate the number one, matching +(m+1).n.


Step-by-Step Solution:

Identify intended starting field: (m+1).Identify intended starting column offset within that field: n.Map to legacy form: +(m+1).n.Choose the option written as +(m+l).n (l standing for 1 in the exam's notation).


Verification / Alternative check:

Modern equivalent: sort -k $((m+1)).$((n+1)) (adjust for exact column semantics). Recognizing that the question tests legacy notation ensures you select the expression that encodes “after nth column of the (m+1)th field.”


Why Other Options Are Wrong:

  • -m.n: wrong flag; minus indicates a different (end) position in some variants.
  • +m.n: starts at the m-th field (not m+1 as asked).
  • + n.m+1: malformed spacing/syntax.
  • None of the above: incorrect because the intended legacy form is present as +(m+l).n.


Common Pitfalls:

  • Mistaking legacy +POS for modern -k usage; on GNU sort, prefer -k.
  • Off-by-one confusion between field/column indexes in different implementations.


Final Answer:

+(m+l).n.

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion