open(command::Cmd, mod::AbstractString="r", s

..  open(command, mode::AbstractString="r", stdio=DevNull)

Start running ``command`` asynchronously, and return a tuple
``(stream,process)``.  If ``mode`` is ``"r"``, then ``stream``
reads from the process's standard output and ``stdio`` optionally
specifies the process's standard input stream.  If ``mode`` is
``"w"``, then ``stream`` writes to the process's standard input
and ``stdio`` optionally specifies the process's standard output
stream.

Examples

Read from a file

julia> fp = open("foo");
julia> print(readall(fp))
"bar"

Append to a file

julia> fp = open("foo","a");
julia> str = "baz";
julia> write(fp, str);
julia> close(fp);
julia> readall("foo")
"barbaz"

Repeat first line

julia> function f(file)
            arr = readlines(file)
            str = arr[1]
            write(file, str)
        end
f (generic function with 1 method)
julia> open(f, "numbers", "r+");    # file contains 1,2,3 in successive lines
julia> readall("numbers")
"1\n2\n3\n1\n"

See Also

deserialize, eachline, eof, fd, flush, IOBuffer, ismarked, isopen, isreadonly, mark, nb_available, open, pipeline, position, read, read!, readavailable, readbytes, readbytes!, readline, redirect_stderr, redirect_stdin, reset, seek, seekend, seekstart, serialize, skip, skipchars, TextDisplay, unmark, write, writemime,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: