Skip to content
Advertisement

Is it possible to extract the contents of a tar file to two directories at the same time with a single command?

What I was curious about is whether I can use a version of the command tar -xvf fileName.tar to accomplish this.

Advertisement

Answer

I recommend to use this script.

#!/bin/bash
mkdir ./directory0
mkdir ./directory1
path="directory"
for catalog in ./"$path"*
do
  tar -xvf fileName.tar -C $catalog
done
Advertisement