Skip to main content
Added redirect append
Source Link
rda
  • 366
  • 1
  • 2
  • 8

Redirect the stdout to /dev/null by appending > /dev/null to any command:

apt-get update > /dev/null

To also redirect stderr to /dev/null append 2>&1:

apt-get update > /dev/null 2>&1

To upgrade or install packages without being prompted for [Y/n] add -y:

apt-get upgrade -y > /dev/null 2>&1
apt-get install <package> -y > /dev/null 2>&1

You could also send it to a log file:

apt-get upgrade -y > script.log 2>&1

A single > will overwrite the file, to log multiple commands use two >>, which will cause the output to be appended to the end of the file:

apt-get update >> script.log 2>&1
apt-get upgrade -y >> script.log 2>&1

Redirect the stdout to /dev/null by appending > /dev/null to any command:

apt-get update > /dev/null

To also redirect stderr to /dev/null append 2>&1:

apt-get update > /dev/null 2>&1

To upgrade or install packages without being prompted for [Y/n] add -y:

apt-get upgrade -y > /dev/null 2>&1
apt-get install <package> -y > /dev/null 2>&1

You could also send it to a log file:

apt-get upgrade -y > script.log 2>&1

Redirect the stdout to /dev/null by appending > /dev/null to any command:

apt-get update > /dev/null

To also redirect stderr to /dev/null append 2>&1:

apt-get update > /dev/null 2>&1

To upgrade or install packages without being prompted for [Y/n] add -y:

apt-get upgrade -y > /dev/null 2>&1
apt-get install <package> -y > /dev/null 2>&1

You could also send it to a log file:

apt-get upgrade -y > script.log 2>&1

A single > will overwrite the file, to log multiple commands use two >>, which will cause the output to be appended to the end of the file:

apt-get update >> script.log 2>&1
apt-get upgrade -y >> script.log 2>&1
Source Link
rda
  • 366
  • 1
  • 2
  • 8

Redirect the stdout to /dev/null by appending > /dev/null to any command:

apt-get update > /dev/null

To also redirect stderr to /dev/null append 2>&1:

apt-get update > /dev/null 2>&1

To upgrade or install packages without being prompted for [Y/n] add -y:

apt-get upgrade -y > /dev/null 2>&1
apt-get install <package> -y > /dev/null 2>&1

You could also send it to a log file:

apt-get upgrade -y > script.log 2>&1