Skip to main content
Markup (minor), correct use of `tar` options, quoting
Source Link
Kusalananda
  • 356.2k
  • 42
  • 737
  • 1.1k

you can use tee command

usb1="/mnt/usbone"
usb2="/mnt/usbtwo"
source="/home/user"

tar -cfzcz -f $- "${source}" | tee $"${usb2}/source.tar.gzgz" > $"${usb1}/source.tar.gzgz"

where

  • -f - tells tartar to use stdout as backup file.
  • tee $"${usb2}/source.tar.gzgz" will copy stdin to specified file and stdout.
  • > $"${usb1}/source.tar.gzgz" will redirect stdout from teetee to file.

you can use tee command

usb1="/mnt/usbone"
usb2="/mnt/usbtwo"
source="/home/user"

tar -cfz - ${source} | tee ${usb2}/source.tar.gz > ${usb1}/source.tar.gz

where

  • -f - tells tar to use stdout as backup file
  • tee ${usb2}/source.tar.gz will copy stdin to specified file and stdout
  • > ${usb1}/source.tar.gz will redirect stdout from tee to file.

you can use tee command

usb1="/mnt/usbone"
usb2="/mnt/usbtwo"
source="/home/user"

tar -cz -f - "${source}" | tee "${usb2}/source.tar.gz" > "${usb1}/source.tar.gz"

where

  • -f - tells tar to use stdout as backup file.
  • tee "${usb2}/source.tar.gz" will copy stdin to specified file and stdout.
  • > "${usb1}/source.tar.gz" will redirect stdout from tee to file.
Source Link
Archemar
  • 32.3k
  • 18
  • 75
  • 107

you can use tee command

usb1="/mnt/usbone"
usb2="/mnt/usbtwo"
source="/home/user"

tar -cfz - ${source} | tee ${usb2}/source.tar.gz > ${usb1}/source.tar.gz

where

  • -f - tells tar to use stdout as backup file
  • tee ${usb2}/source.tar.gz will copy stdin to specified file and stdout
  • > ${usb1}/source.tar.gz will redirect stdout from tee to file.