Skip to content

Instantly share code, notes, and snippets.

View ayushgoel's full-sized avatar

Ayush ayushgoel

View GitHub Profile
@ayushgoel
ayushgoel / shell-commands.rb
Last active August 29, 2015 14:22 — forked from JosephPecoraro/shell-execution.rb
Running shell commands from ruby
# Ways to execute a shell script in Ruby
cmd = "echo 'hi'" # Sample string that can be used
# 1. Kernel#` - commonly called backticks - `cmd`
# This is like many other languages, including bash, PHP, and Perl
# Returns the result of the shell command
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111
value = `echo 'hi'` # or uglier but valid => Kernel.`("echo 'hi'")