Ruby: Call Shell Command

By Xah Lee. Date: .

Use backticks `command_string` to call a shell command.

# ruby

# call shell commands
puts `dir`

# sample output on Microsoft Windows

=begin

 Volume in drive C is Windows
 Volume Serial Number is 86F8-588E

 Directory of c:\Users\xah\.emacs.d\temp

12/26/2022  07:48 PM    <DIR>          .
12/26/2022  07:48 PM    <DIR>          ..
12/18/2022  02:55 PM                68 x20221218_1455_f80.orig.txt
12/18/2022  06:18 PM                 0 x20221218_1455_f80.wl~2022-12-18_181842~
12/22/2022  03:03 PM             1,786 x20221222_1213_221.wl~2022-12-22_150348~
12/22/2022  03:18 PM             1,250 x20221222_1213_221.wl~2022-12-22_151844~
12/24/2022  10:48 AM               550 x20221224_1048_df3.el~2022-12-24_104831~
12/25/2022  10:14 AM             2,624 x20221225_1008_7c3.el~2022-12-25_101434~
12/26/2022  07:48 PM                54 x20221226_1948_ecb.orig.txt
12/26/2022  07:49 PM               286 x20221226_1948_ecb.rb
09/25/2022  06:43 PM               406 xx.json
               9 File(s)          7,024 bytes
               2 Dir(s)  72,053,006,336 bytes free

=end