I desire to run a cat
heredocument in a single row instead the natural syntax of 3 rows (opener, content, and delimiter). My need to do so is mostly aesthetic as the redirected content aimed aimed to be part of a handbook text file and I would like to save as much rows as I can, in that particular file).
Doing cat <<< TEST > ~/myRep/tiesto tiesto TEST
(what I would normally split for 3 parts) results in an errors:
tiesto: No such file or direcotry
TEST: No such file or directory.
Is it even possible to execute one-row heredocuments in Bash?
Best Answer
Yes, but you'd be using a an here-string rather than a here-document:
This will send the string
tiesto
tocat
on its standard input, and it will write the string to the file$HOME/myRep/tiesto
through a redirection of its standard output.Note that here-strings are not standard but are implemented by at least
zsh
(where it comes from, at the same time as the UNIX version ofrc
, though thatrc
and its derivatives likees
orakanga
don't add an extra newline character in the end),ksh93
,bash
,mksh
andyash
.