psql shell command execution with \!
Seems to be impossible for \!
,
but one can set a variable from external command output,
testdb=> \set content `cat my_file.txt`
and then using this var in sql expression like this:
testdb=> INSERT INTO my_table VALUES (:'content');
You can use \o <filename>
option to specify the output file or use COPY
command to solve your problem.