> 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/e/execute_a_system_command.md).

# Execute a system command

```ruby
# Pipe in read-only mode
%p(ls).open_r.each { |line|
    print line;
};
 
var str1 = `ls`;         # backtick: returns a string
var str2 = %x(ls);       # ditto, alternative syntax
 
Sys.system('ls');   # system: executes a command and prints the result
Sys.exec('ls');     # replaces current process with another
```
