Can you use the tac command in Terminal?
I'm trying to search a large file in reverse ord开发者_Go百科er from the command line (using terminal). I found the tac command: http://clifgriffin.com/2008/11/25/tac-and-reverse-grep/
tac is the inverse of cat. However, when I try to use the tac command in terminal, it says that command doesn't exist. Is there a way I'd be able to use tac in terminal? What are some other fast ways to search a file from the end via the command line?
The MacOs version of tail
support the -r
("reverse") option, and defaults
to displaying the entire file from the end. So tail -r filename
should be
exactly equivalent to tac filename
.
Or, you could try building tac yourself from the source code. It's part of the GNU coreutils package.
It's easy using OSX Homebrew:
brew install coreutils
Then it's available as gtac
(as in GNU tac), for example:
# Find and parallel copy all files in reverse order
find . -print | gtac | parallel copy "{}" destination/
精彩评论