Custom date format for csh(1) history – FreeBSD and TrueNAS CORE

https://man.freebsd.org/cgi/man.cgi?query=tcsh&sektion=1&manpath=freebsd-current

On FreeBSD 15.0-CURRENT, I changed python to python3 then tested the command with tail as well as head.

Can anyone tell why I get a broken pipe with head?

Thanks

root@mowa219-gjp4-zbook-freebsd:~ # cat .history | python3 -c 'from datetime import datetime as dt; import sys; lines=[l for l in sys.stdin]; chunks=[lines[i:i + 2] for i in range(0, len(lines), 2)]; [print(dt.fromtimestamp(int(time[2:])), cmd.strip()) for time, cmd in chunks]' | tail -n 20
2025-04-21 08:38:32 cat /usr/local/poudriere/data/logs/bulk/current-default/2025-04-21_08h36m00s/logs/errors/virtualbox-ose-kmod-70-7.0.24.1500038.log
2025-04-21 08:39:06 date ; uptime ; uname -mvKU
2025-04-21 08:39:18 poudriere jail -i -j current
2025-04-21 08:47:17 history | grep 1500038
2025-04-21 09:50:10 bectl list -c creation | tail -n 6
2025-04-22 03:56:39 head -n 5 .history
2025-04-22 03:57:21 tail -n 5 .history
2025-04-22 03:57:32 tail -n 20 .history
2025-04-22 03:59:28 head -n 5 .history
2025-04-22 03:59:35 history -S
2025-04-22 03:59:39 head -n 5 .history
2025-04-22 04:02:25 file /tmp/1500036-005-base/root/.history
2025-04-22 04:02:35 file /tmp/1500036-006-base/root/.history
2025-04-22 04:02:44 file /tmp/1500037-001-base/root/.history
2025-04-22 04:03:03 du -hs .history
2025-04-22 04:03:08 wc -l .history
2025-04-22 04:03:18 history -S
2025-04-22 04:03:28 tail -n 20 .history
2025-04-22 04:04:09 head -n 5 .history
2025-04-22 04:17:34 history -S
root@mowa219-gjp4-zbook-freebsd:~ # cat .history | python3 -c 'from datetime import datetime as dt; import sys; lines=[l for l in sys.stdin]; chunks=[lines[i:i + 2] for i in range(0, len(lines), 2)]; [print(dt.fromtimestamp(int(time[2:])), cmd.strip()) for time, cmd in chunks]' | head -n 20
2025-03-20 22:02:49 ping -4 -c 2 freshports.org
2025-03-20 22:02:54 bectl list -c creation | tail -n 6
2025-03-20 22:03:02 bectl activate 1500034-025-base
2025-03-20 22:03:07 uname -bmvKU
2025-03-20 22:03:37 poudriere jail -u -j current
2025-03-20 22:03:42 pkg update
2025-03-20 22:03:49 tail -n 6 /home/grahamperrin/Documents/boot\ environments.txt
2025-03-20 22:04:18 poudriere ports -u
2025-03-20 22:04:30 zpool import Transcend ; zpool status Transcend && zfs load-key Transcend/VirtualBox && zfs mount Transcend/VirtualBox ; mount | grep Transcend ; sleep 5 ; zpool iostat -v
2025-03-20 22:04:55 zpool status -x
2025-03-20 22:26:18 find /var/run -name "*.pid" -print
2025-03-20 22:26:23 find /var/run -name "*.pid" -ls
2025-03-20 22:37:04 ls -l /var/run/clamav/
2025-03-20 22:37:39 clamd
2025-03-20 22:38:00 file /var/log/clamav/
2025-03-20 22:38:18 pkg info clamav
2025-03-20 22:39:02 turbo /usr/local/etc/clamd.conf
2025-03-20 22:40:37 file /var/log/clamav
2025-03-20 22:40:41 mkdir -p /var/log/clamav
2025-03-20 22:40:43 clamd
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "<string>", line 1, in <listcomp>
BrokenPipeError: [Errno 32] Broken pipe
root@mowa219-gjp4-zbook-freebsd:~ #