Skip to content

Instantly share code, notes, and snippets.

@thinkerbot
Created January 24, 2011 21:55
Show Gist options
  • Save thinkerbot/794045 to your computer and use it in GitHub Desktop.
Save thinkerbot/794045 to your computer and use it in GitHub Desktop.
examples of handling newlines in ruby shell-out
# echo -e "abc\nabc"
# echo -e "xyz\
# xyz"
puts `echo "abc\nabc"`
puts `echo "xyz\
xyz"`
abc = "abc\nabc"
puts `echo "#{abc}"`
xyz = "xyz\
xyz"
puts `echo "#{xyz}"`
abc = %Q{echo "abc\nabc"}
puts `#{abc}`
xyz = %Q{echo "xyz\
xyz"}
puts `#{xyz}`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment