Macaulay2 » Documentation
Packages » Macaulay2Doc » The Macaulay2 language » system facilities » using sockets » get
next | previous | forward | backward | up | index | toc

# get -- get the contents of a file

- Usage:
    `get f`
- Inputs:
  - f, a file or a string. If f is a string, then it is opened, as with openIn. Filenames starting with ! or with $ are treated specially, see openInOut.
- Outputs:
  - a string containing the contents of the file. If the file was already open and partially read, the remainder of the contents of the file are returned.
- Consequences:
  - In the case where f is a file, its input side is closed.

## Description

    i1 : "test-file" << "hi there" << close

    o1 = test-file

    o1 : File

    i2 : get "test-file"

    o2 = hi there

    i3 : removeFile "test-file"

    i4 : get "!date"

    o4 = Sun Feb  8 12:04:04 UTC 2026

## See also

- read -- read from a file
- removeFile -- remove a file
- close -- close a file
- File << Thing -- print to a file

## Ways to use get:

- `get(File)`
- `get(String)`

## For the programmer

The object get is a compiled function.

The source of this document is in /build/macaulay2-88fgJW/macaulay2-1.25.11+ds/M2/Macaulay2/packages/Macaulay2Doc/ov_system.m2:340:0.