I'm imagining cat /etc/hostname | hostname [something to add the first command's output here]
.
What do we use to represent the first commands output?
It's to not have to copy paste the output manually and use in automation when needed.
I'd like to use just one or two characters (like $1 or a < or something) to represent whatever command 1 outputs to STDOUT, but 'paste' it anywhere I want in following command 2 or 3.
If <
or another symbol character represents my STDOUT(put) from file.txt and the file content is google.com
for example, let's say I'd want to run
$ cat file.txt | ping <
or
$ cat file.txt | hostname <
to set the hostname to google.com
, or countless other use cases for daily usage.
((Without using environment variables)).
ping "$(cat file.txt)"
/hostname "$(cat file.txt")
; orcat file.txt | xargs -I % ping %
(if you want to control where in the command line the input is placed)cat file.txt | xargs ping
(if you're OK with arguments just appearing at the end. – muru Jan 19 '23 at 04:03