I have this multilinie heredocument which I desire to translate into a uniline herestring:
cat <<-"PHPCONF" > /etc/php/*/zz_overrides.ini
[PHP]
post_max_size = 200M
upload_max_filesize = 200M
cgi.fix_pathinfo = 0
PHPCONF
The closest I could get is as follows:
cat >"/etc/php/*/zz_overrides.ini" <<< "[PHP] post_max_size = 200M upload_max_filesize = 200M cgi.fix_pathinfo = 0"
but I don't think line breaks after each directive is possible, given the end result is one string. Maybe there is some "unorthodox" way after all?
Both the heredoc, and herestring, are aimed to replace this heavy sed operation:
sed -i "s/post_max_size = .M/post_max_size = 200M/ ; s/upload_max_filesize = .M/upload_max_filesize = 200M/ ; s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php/*/fpm/php.ini
printf? e.g.printf ' [PHP]\n post_max_size = 200M\n upload_max_filesize = 200M\n cgi.fix_pathinfo = 0\n'touch+&&may be handy, because AFAIK, one cannot create a file withprintf.printfoutput to a file (which will create it if it doesn't exist)catdoesn't create files either. The redirection that you use creates the file.