Advertisement

09.17.2007 at 11:34PM PDT, ID: 22835244
[x]
Attachment Details

sorting file in Unix shell script

Asked by hongbinzhang711 in Bourne-Again Shell (bash), Shell Scripting

Tags: shell, sort, script, unix, file

I have a file with content:
       AAA   10
       AAA   1
       AAA   2
       CCC    1
       CC C   0
       BBB    20
       BBB    1
how can I use Unix sort to sort this file to sort field 1 as text and field 2 as numeric?

sort -k1,2n does not work.
Start Free Trial
[+][-]09.17.2007 at 11:39PM PDT, ID: 19910622

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.17.2007 at 11:44PM PDT, ID: 19910647

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.17.2007 at 11:55PM PDT, ID: 19910693

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.18.2007 at 12:07AM PDT, ID: 19910737

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Bourne-Again Shell (bash), Shell Scripting
Tags: shell, sort, script, unix, file
Sign Up Now!
Solution Provided By: ozo
Participating Experts: 3
Solution Grade: B
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_1_20070628