Has anyone written the GNU cat command in python and would be willing to share? GNU cat actually does quite a bit & I don’t really feel like re-inventing the wheel today. Yes, I did do a google search & and after reading too many sad stories of kittens vs snakes I decided to try SO.
Edit: I’d like to modify it so that it only shows unique lines.
That depends which functionalities you want. If you just want to print out a file, you can do
or to concatenate some files, you could do
There is no general answer. Depending on the functionality you want to replicate, your code will be different. To exactly replicate something odd and special, use the
subprocessmodule and call cat.If you want to implement the same interface as cat, that seems an odd requirement. You can call cat and you can write the code more naturally. The only reason I can think to completely reimplement cat is for homework, and I would hope you wouldn’t ask for the finished product if that is your reason.