If I have a file called test.php
and its contents are
$a = "apple";
echo PHP_EOL;
echo " the value of \$a is $a" . PHP_EOL;
I want to cat the contents of test.php
to STDOUT but I want to add a header string <?php
to the beginning of the output. My desired outcome is to run a command like
% cat ..... test.php
desired output in terminal
<?php
$a = "apple";
echo PHP_EOL;
echo " the value of \$a is $a" . PHP_EOL;
I have tried assigning the string <?php
to a variable and concatenating the variable with a here-string, e.g.
% php='<?php'
% cat <<<$php
<?php
% cat <<<$php test.php
$a = "apple";
echo PHP_EOL;
echo " the value of \$a is $a" . PHP_EOL;
When I try to concat
enate a here-string to a file the here-string is ignored.
How can I insert a header into the STDOUT before the cat
'ed file?
cat - test.php <<<$php
? – muru May 14 '16 at 00:20-
tells cat to print stdin input, which in this case should come before the filename. – muru May 14 '16 at 00:30