Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

Those features simply do not belong in a program whose purpose is to concatenate its input. If you want to number a file's lines, 'echo ,n | ed file | sed 1d' or 'awk ''{ print NR " " $0 }''' will do just fine. You could even wrap your ed or awk script into a shell script with a descriptive name like "lineno" rather than something silly like "cat -n". The reason GNU's is so complex is because it does many things and does them poorly. The V6 implementation does exactly what is says on the tin, does it well, and does nothing more: it catenates files.


I am confused by your definition of "poorly". Are you asserting that GNU cat is slow, or unportable, or uses too much memory, or some other actual noticeable problem?



But now you've spawned many processes when one could have been used, and you'll incur the wrath of people that think that 'grep foo file' is 1000x more efficient than 'cat file | grep foo'.


I liked your use of ed. You can avoid one pipe with the -s option: `echo ,n | ed -s file`. Also, another POSIX one-process option besides awk: `pr -tn file` (with different padding).




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: