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

Re: which command I should use to output sequentially,



Might I recommend a plethora of free database solutions available to you?

I see this type of question quite frequently and am stunned to see such a thing here (or on other mailing lists for platforms just a poorly suited for such data). I'm not sure what your data is from or what it is for but I almost guarantee you that it should be in a database. Either that or open LibraOffice calc and do the one off data task in a few minutes and be done with it.

Either way, there's generally a right tool for the job and I highly doubt that bash, cut, tr, grep, sed, awk, etc are the hammers you really want to use for this nail.

On Jul 27, 2011 1:49 AM, "lina" <lina.lastname@gmail.com> wrote:
> On Wed, Jul 27, 2011 at 1:36 PM, Ivan Shmakov <ivan@gray.siamics.net> wrote:
>>>>>>> lina  <lina.lastname@gmail.com> writes:
>>
>>        First of all, a kindly reminder: there's a news:comp.unix.shell
>>        newsgroup (also available via Google Groups [1], though a proper
>>        newsreader software is recommended), with a few truly
>>        knowledgeable folks among the subscribers, which such questions
>>        should've been pointed to.
>>
>> [1] http://groups.google.com/group/comp.unix.shell/
>>
>> […]
>>
>>  > I just remember the sort command, but I still don't know how to get
>>  > the ideal one,
>>
>>  > after I tried the sort -n -k2 , something changed on field 2 but it's
>>  > still a bit away from the one I need.
>>
>>        Unfortunately, the numeric (-n) sort cannot be performed over
>>        the field that contains numbers prefixed with arbitrary strings.
>>        Therefore, it's necessary to split such a field into the
>>        separate prefix and number parts, like (assuming GNU Sed):
>>
>> $ sed -e 's/^\(\s*\w\+\s\+[^0-9[:blank:]]\+\)\([[:digit:]]\+\)/\1 \2/'
>>  238CHO   C10 3617   1.697   5.334   9.317
>>  238CHO   C11 3624   1.665   5.468   9.092
>> ^D
>>  238CHO   C 10 3617   1.697   5.334   9.317
>>  238CHO   C 11 3624   1.665   5.468   9.092
>> $
>>
>>        Then, the output may be sorted on the now-third column, and the
>>        extra space removed.  Thus:
>>
>> $ 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,
>
>
> 237CHOL H29 3583 3.341 1.693 9.809
> 237CHOL O28 3584 3.416 1.677 9.744
> 237CHOL C3 3585 3.383 1.746 9.624
> 237CHOL C4 3586 3.266 1.686 9.544
> 237CHOL C5 3587 3.251 1.760 9.411
> 237CHOL C10 3588 3.373 1.749 9.320
> 237CHOL C1 3589 3.483 1.814 9.404
> 237CHOL C2 3590 3.511 1.748 9.540
> 237CHOL C6 3591 3.135 1.819 9.381
> 237CHOL C7 3592 3.112 1.886 9.245
> 237CHOL C8 3593 3.216 1.831 9.148
> 237CHOL C9 3594 3.364 1.825 9.187
> 237CHOL C11 3595 3.450 1.764 9.077
> 237CHOL C12 3596 3.432 1.853 8.954
> 237CHOL C13 3597 3.287 1.843 8.907
> 237CHOL C14 3598 3.201 1.907 9.017
> 237CHOL C15 3599 3.063 1.908 8.953
> 237CHOL C16 3600 3.085 1.906 8.803
> 237CHOL C17 3601 3.235 1.912 8.782
> 237CHOL C19 3602 3.380 1.597 9.303
> 237CHOL C18 3603 3.247 1.695 8.905
> 237CHOL C20 3604 3.293 1.855 8.652
> 237CHOL C21 3605 3.438 1.900 8.642
> 237CHOL C22 3606 3.216 1.907 8.530
> 237CHOL C23 3607 3.244 1.802 8.423
> 237CHOL C24 3608 3.141 1.831 8.313
> 237CHOL C25 3609 3.207 1.836 8.175
> 237CHOL C26 3610 3.107 1.805 8.064
> 237CHOL C27 3611 3.247 1.982 8.150
> 238CHOL H29 3612 1.573 5.345 9.781
> 238CHOL O28 3613 1.640 5.282 9.743
> 238CHOL C3 3614 1.609 5.284 9.603
> 238CHOL C4 3615 1.702 5.187 9.529
> 238CHOL C5 3616 1.689 5.193 9.376
> 238CHOL C10 3617 1.697 5.334 9.317
> 238CHOL C1 3618 1.598 5.425 9.390
> 238CHOL C2 3619 1.623 5.423 9.541
> 238CHOL C6 3620 1.693 5.077 9.310
> 238CHOL C7 3621 1.697 5.086 9.157
> 238CHOL C8 3622 1.741 5.222 9.102
> 238CHOL C9 3623 1.663 5.336 9.168
> 238CHOL C11 3624 1.665 5.468 9.092
> 238CHOL C12 3625 1.638 5.452 8.942
> 238CHOL C13 3626 1.734 5.354 8.874
> 238CHOL C14 3627 1.709 5.225 8.952
> 238CHOL C15 3628 1.784 5.122 8.869
> 238CHOL C16 3629 1.739 5.167 8.731
> 238CHOL C17 3630 1.696 5.313 8.733
> 238CHOL C19 3631 1.839 5.384 9.345
> 238CHOL C18 3632 1.878 5.403 8.892
> 238CHOL C20 3633 1.764 5.397 8.625
> 238CHOL C21 3634 1.739 5.546 8.648
> 238CHOL C22 3635 1.747 5.342 8.484
> 238CHOL C23 3636 1.855 5.386 8.384
> 238CHOL C24 3637 1.808 5.343 8.245
> 238CHOL C25 3638 1.906 5.379 8.134
> 238CHOL C26 3639 1.851 5.324 8.002
> 238CHOL C27 3640 1.940 5.528 8.123
>
>>
>> --
>> FSF associate member #7257
>>
>>
>> --
>> To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
>> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
>> Archive: [🔎] 86livkp9o3.fsf@gray.siamics.net">http://lists.debian.org/[🔎] 86livkp9o3.fsf@gray.siamics.net
>>
>>
>
>
>
> --
> Best Regards,
>
> lina
>
>
> --
> To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
> Archive: http://lists.debian.org/CAG9cJmn8bqNTJEgxeEiUAAg462oOK_awi3GAPd-D-dSdGiDUw@mail.gmail.com
>

Reply to: