[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: which command I should use to output sequentially,



>>>>> lina  <lina.lastname@gmail.com> writes:
>>>>> On Wed, Jul 27, 2011 at 1:36 PM, Ivan Shmakov wrote:

[…]

 >> $ sed -e 's/^\(\s*\w\+\s\+[^0-9[:blank:]]\+\)\([[:digit:]]\+\)/\1 \2/' \
 >>      | sort -nk 3,3 -k1,1 \
 >>      | sed -e 's/^\(\s*\w\+\s\+[^0-9[:blank:]]\+\)\s\([[:digit:]]\+\)/\1\2/'

 > Thanks, but there is another problem here, about the first field,
 > which I wish it can be consequentially (mainly keep it present
 > sequential), Here is the list, a bit longer,

	Somehow, I've had the -k options order reversed in the code
	above.  It should've read: … | sort -n -k 1,1 -k 3,3 | …
	instead.

	Note that there we're sorting numerically on the first field,
	too.  If that's undesirable, sort(1) is to be invoked twice,
	like: … | sort -n -k 3,3 | sort -s -k 1,1 | ….

[…]

-- 
FSF associate member #7257


Reply to: