Monday, April 25, 2016

uniq shell quickie quirks

I had a bunch of small text files in a directory, on some CENTos system, and I was pleased to realize
more *txt | cat
would print each file name as well as the contents.  But it didn't work in my default MacOS shell. This stackoverflow gave me a better idea:
grep "." *txt
which is nice because it was leaving out the empty files - it also did the format "filename:contents" which worked ok for my needs.

Ok, not rocketscience, but a reminder that different Unix-y shells have different implementations of some basic text manipulation commands.

No comments:

Post a Comment