Next: file misc, Previous: file testing, Up: file [Contents][Index]
The following functions perform actions that can normally be done directly with the redirection operators of Bash:
# write to a file printf '%s' "$string" >"$filename" # append to a file printf '%s' "$string" >>"$filename" # read a file, print contents printf '%s' "$(<$filename)"
The functions act differently in that they spawn a bash
subprocess, by invoking mbfl_program_exec()
, and let it do the
operation; this allows us to request the usage of sudo
and so
to read and write files with modified privileges, but only for the time
needed to do the operation, not for the whole script.
Write string to filename, eventually creating it or overwriting old contents.
Append string to filename, eventually creating it.
Read and print all the contents of filename.
Next: file misc, Previous: file testing, Up: file [Contents][Index]