Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Sorting a text file after the 3rd token (NOT column)?

3 views
Skip to first unread message

Dennis Halver

unread,
Jun 25, 2009, 2:08:17 AM6/25/09
to
I start with a textfile which contains lines with multiple words each line.
The words are separated by one or more blanks.

Now I want to sort this text file but not after the 3rd column resp. 3rd character in a line
but after the 3rd token. Sample:

original:

wwwwwww ddd ddddd dddd dddd
xxxxxxxxx cc cc ccccc
yyyy bbb bbbbbbbbbbbbbbbb
zzz aaaaaa aaaa aa a aaa

should be after sort:

zzz aaaaaa aaaa aa a aaa
yyyy bbb bbbbbbbbbbbbbbbb
xxxxxxxxx cc cc ccccc
wwwwwww ddd ddddd dddd dddd

How can I do this within a MSDOS batch script?

Dennis

Richard Bonner

unread,
Jun 27, 2009, 7:40:47 AM6/27/09
to

> original:

> How can I do this within an MS-DOS batch script?

> Dennis

*** The DOS "SORT" command sorts by character position, but some
third-part SORT commands may allow token sorting. Look here for other
SORT commands:

http://www.chebucto.ca/~ak621/DOS/Websites.html


That aside, XSET can recognise and manipulate tokens via its "/WORD"
and "/SEPARATOR" features regardless of what character is used to separate
tokens. However, I have never written a batch file that sorts by them.

Finally, the 4DOS "FOR" command can parse text via its `/F' switch.
Again, I have never used it to sort output via tokens. Both 4DOS and XSET
links are in the previous URL.
--------

Sorry I can't be of more precise help; I am just getting back into
newsgroups after a five-month stretch of an almost 7-day-a-week work
season. Post here again and I may be able to take some time to whip up a
batch file - I like the idea of a such a task.

Richard Bonner
http://www.chebucto.ca/~ak621/DOS/

bud

unread,
Jun 28, 2009, 12:55:39 AM6/28/09
to

Group: comp.os.msdos.misc Date: Sat, Jun 27, 2009, 11:40am (CDT+5) From:
ak...@chebucto.ns.ca (Richard Bonner)

script:
                               
>… I am just getting back into newsgroups
>after a five-month stretch …

Welcome back Richard!

salaam,
dowcom

To e-mail me, add the character zero to "dowcom". i.e.:
dowcom(zero)(at)webtv(dot)net.

The fact that 'conventional wisdom' is indeed 'conventional',
does not, in any way, imply that it is wise.

Richard Bonner

unread,
Jun 30, 2009, 1:05:06 PM6/30/09
to
You wrote:
>
> Group: comp.os.msdos.misc Date: Sat, Jun 27, 2009, 11:40am (CDT+5) From:
> ak...@chebucto.ns.ca (Richard=A0Bonner)

> script:
> >=85 I am just getting back into newsgroups
> >after a five-month stretch =85

> Welcome back Richard!
>
> dowcom

*** Thanks. It went crazy this year, but I was glad for all the work.
Here are photos of a few of the events:

http://AIEL.chebucto.biz/Gallery/

Richard Bonner
http://www.chebucto.ca/~ak621/DOS/

0 new messages