Here are my additional notes on Ruby shell scripting from here.
-
Backticks (or back-ticks) let you do some scripting stuff a lot easier. Consider
puts `find . | grep -i lib`
-
If you run into problems with getting the output of backticks, the stuff is going to standard err instead of standard out. Use this advice
out = `git status 2>`
-
Backticks do string interpolation:
blah = 'lib'
`touch #{blah}`
-
You can pipe inside Ruby, too. It's a link to my blog, but it links back here so it's okay :) There are probably more advanced things out there on this topic.
-
As other people noted, if you want to get serious there is Rush: not just as a shell replacement (which is a bit too zany for me) but also as a library for your use in shell scripts and programs.
1 comment:
I should mention that Rush has no current maintainer, so that makes it less than attractive.
http://groups.google.com/group/ruby-shell/browse_thread/thread/75c8cea757d2f680#
Post a Comment