Mwnci cat() Function

Syntax

cat(filename)
bzcat(filename)
gzcat(filename)

Description

The cat() function returns the contents of file filename as a single string. cat() makes an initial check of the file contents before reading and will use the appropriate inner function to read the contents. That is bzcat() or gzcat() will be used to read a file, depending on the compression method.

The cat(), bzcat(), and gzcat() built-ins can be used separately should you not want to rely on cat() to discerninmg the file contents/type.

Example

filename="/etc/passwd"
lines=split(cat(filename), "\n")   //split the single string by newline
foreach line in lines {
    println(line)
}

...
...
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
systemd-timesync:x:100:102:systemd Time Synchronization,,,:/run/systemd:/usr/sbin/nologin
systemd-network:x:101:103:systemd Network Management,,,:/run/systemd:/usr/sbin/nologin
...
...


// A simpler version
print(cat("/etc/passwd"))