sort + head = weirdness?
From: Mark (unixadmin_at_livebridge.com)
Date: 10/02/03
- Next message: Terry Carpenter: "How to find certain newlines and delete them in ksh."
- Previous message: saurabh: "Re: more search ean replace with sed"
- Next in thread: Barry Margolin: "Re: sort + head = weirdness?"
- Reply: Barry Margolin: "Re: sort + head = weirdness?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 01 Oct 2003 15:29:17 -0700
This is really weird. I'm catting a text file, piping it through
'sort'and then through 'head' and I'm getting really strange results.
This only affects files > 4096 bytes.
It's only a problem when piping through 'head'; 'tail' works fine.
It's only a problem when piping through a file containing 'sort'; it
works fine with 'sort' itself.
(The test file is just a text file containing the numbers 1-9 repeated.)
('format' is a file containing the single word 'sort'. Eventually this
will contain other formatting commands.)
So, here's what happens:
With a file 4096 bytes or less it works fine.
# ls -al testfile -rw-rw-r--
1 root root 4096 Oct 1 14:46 testfile
# cat testfile | format | head -1
12345
If I add one more character to the file, it fails.
# ls -al testfile
-rw-rw-r-- 1 root root 4097 Oct 1 14:38 testfile
# cat testfile | format | head -1
123456
/usr/local/bin/drs/format: line 1: 8688 Broken pipe sort
If, with the same 4097 byte file I replace 'head' with 'tail', it works
fine.
# cat testfile | format | tail -1
123456789
If I replace 'format' with 'sort' it works fine.
# cat testfile | sort |head -1
123456
Any idea what's going on here? Is there some buffer somewhere that can
only take 4k of data?
Mark
- Next message: Terry Carpenter: "How to find certain newlines and delete them in ksh."
- Previous message: saurabh: "Re: more search ean replace with sed"
- Next in thread: Barry Margolin: "Re: sort + head = weirdness?"
- Reply: Barry Margolin: "Re: sort + head = weirdness?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|