I need to be able to alphabetically sort the output of find before piping it to a command. Entering | sort | between didn't work, so what could I do?
find folder1 folder2 -name "*.txt" -print0 | xargs -0 myCommand
|
|
|
Leave the newlines in (just a standard -print), then sort, then remove the newlines:
|
|||||
|
|
Some versions of
Additionally, you could also write a high-level script to do it:
Add the |
|||
|
|
I think you need the According to man sort:
edit The print0 may have something to do with this, I just tested this. Take the print0 out, you can null terminate the string in sort using the |
||||
|
|
If you have GNU Parallel http://www.gnu.org/software/parallel/ installed you can do this:
You can install GNU Parallel simply by:
Watch the intro videos for GNU Parallel to learn more: https://www.youtube.com/playlist?list=PL284C9FF2488BC6D1 |
|||
|
|