0

What does tee do and is it possible to run this command in a alternative way with suppressing the output?

#!/bin/bash
echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" | sudo tee /etc/apt/sources.list.d/docker.list
user3142695
  • 15,844
  • 47
  • 176
  • 332

1 Answers1

0

The command

echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" | sudo tee /etc/apt/sources.list.d/docker.list

is an indirect way of saying:

echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" > /etc/apt/sources.list.d/docker.list

as root.

You see the output on the terminal because of the tee command.

You can rewrite it as below, to suppress the output, while running as non-root user:

echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" | sudo sh -c "cat > /etc/apt/sources.list.d/docker.list"

See also:

Community
  • 1
  • 1
codeforester
  • 39,467
  • 16
  • 112
  • 140