So im trying to create a script that looks in a folder and finds all the file types that have .cpp and run g++ on them. so far i have but it doesn't run it says unexpected end
for i in `find /home/Phil/Programs/Compile -name *.cpp` ; do echo $i ;
done
Thanks
The problem with your code is that the wildcard *
is being expanded by the shell before being passed to find. Quote it thusly:
for i in `find /home/Phil/Programs/Compile -name '*.cpp'` ; do echo $i ; done
xargs
as suggested by others is a good solution for this problem, though.
find
has an option for doing exactly that:
find /p/a/t/h -name '*.cpp' -exec g++ {} \;
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