> For the complete documentation index, see [llms.txt](https://trizen.gitbook.io/sidef-lang/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trizen.gitbook.io/sidef-lang/programming_tasks/g/get_system_command_output.md).

# Get system command output

Using backticks:

```ruby
var output = `ls`            # `output` is a string
var lines  = `ls`.lines      # `lines` is an array
```

Using pipes:

```ruby
var pipe   = %p(ls)           # same as: Pipe('ls')
var pipe_h = pipe.open_r      # open the pipe for reading
var lines  = []               # will store the lines of the output
pipe_h.each { |line| lines << line }
```
