Sample Header Ad - 728x90

How to do `head` and `tail` on null-delimited input in bash?

22 votes
2 answers
5210 views
find command can output names of files as a null-delimited strings (if -print0 is provided), and xargs can consume them with -0 option turned on. But in between, it's hard to manipulate that collection of files - sort command has -z switch, that makes it possible to sort those files, but head and tail don't have them. How can I do head and tail on those null-delimited inputs in a convenient way? (I can always create a short & slow ruby script, but I hope that there could be a better way)
Asked by Rogach (6533 rep)
May 9, 2013, 03:06 AM
Last activity: Apr 26, 2023, 10:51 AM