What's the difference between these two commands?
find . -name "*.cpp" -exec sort \;
find . -name "*.cpp" | sort
The first command runs sort (without an argument) for every file which is found by the criteria specified. This is (as Mat has pointed out in his answer) is quite useless. The way to get sort to run for every file is to say find . -name "*.cpp" -exec sort {} \;. This would be like running sort a.cpp; sort b/c.cpp; ... for every file matched.
The second produces a list of .cpp files and then pipes the list through sort producing a sorted list of cpp files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With