3 ms·
That Bash script looks a little irky…just imagine more than one level of directories, and `` is both none-portable and overly ugly, at least compared with $()…n
by claudius 14y ago
That Bash script looks a little irky…just imagine more than one level of directories, and `` is both none-portable and overly ugly, at least compared with $()…not to mention that Shell expansion (for i in $basedir/⁕.{c,h}) should work equally well :)
Anyway, I would rather suggest something like:
find . \( -name '*.c' -o -name '*.h' \) -exec printf "Doing Stuff on {}\n" \; -exec head -n 1 {} \;
- df3n5 14y agoYour bash foo eclipses mine, thank you for the bash schooling! I've updated the script on my original post and gave you credit, hope that's okay.
- claudius 14y agoSure, feel free to do whatever you like with that. Bash is more or less the only scripting language I know/use, so it is only natural to find shortcuts over the years :)
- df3n5 14y agoThanks! :D
- csense 14y ago> Bash is more or less the only scripting language I know/use I feel sorry for you. Try Python, especially if you're doing anything involving string processing.
- claudius 14y agoThanks, but I used Python once for a little FUSE module (long story…) and didn’t particularly like it. If anything, I’d rather try Perl - but then, you can do so much with a sensible Shell and the coreutils, the need to even write a proper script rather than a large concatenation of pipes is a rare event for me. So I guess I’ll stick to Bash and use whatever-is-best if that’s not enough.