0

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)).

Filip
  • 1
  • 1
  • 1
    Related: [How to pass the output of one command as the command-line argument to another?](https://unix.stackexchange.com/questions/4782/how-to-pass-the-output-of-one-command-as-the-command-line-argument-to-another) – steeldriver Jan 18 '23 at 21:42
  • Also: [How to pipe output of a command to another command (which does not take a file as input?)](//unix.stackexchange.com/q/732065) – Stéphane Chazelas Jan 18 '23 at 22:58
  • Either `ping "$(cat file.txt)"`/`hostname "$(cat file.txt")`; or `cat 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

0 Answers0