Tuesday, February 22, 2022

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

Issue

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


Solution

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


Answered By - Vadim Chernetsov
Answer Checked By - Senaida (WPSolving Volunteer)