top of page
Streams and objects

The ls operator lists files, like any Linux shell. But there are important differences. The Linux ls executable prints strings describing files, either multiple file names per line; or, if you specify the -l flag, then one file per line, with each line including file attributes such as mode, modification time, owner, group, and others. I.e., the printing and formatting logic is part of the ls executable.

By contrast, marcel's ls operator generates a stream of File objects, and has no responsibility for printing or formatting -- if you run help ls you will see no such options.

The stream of File objects generated by ls can be passed to the output operator, out:

out takes a stream of objects, and prints each, one per line. The net effect is a listing very much like what you would see by running ls -l from bash.

You can almost always omit explicitly using the out operator. Marcel appends out to your command line, if you don't specify it yourself. So you can get the same listing of files by just writing ls. You do need to specify out explicitly if you want to write to a file, instead of to the console, or to control formatting. For example, to save the ls result in /tmp/files:

There is no output to the console, because the output from ls was written to /tmp/files.

bottom of page