Jenny M Jenny M - 3 months ago 22
Bash Question

create new script to tar file return error

I've create script which (under the root folder on my machine) , to create two folder and take from the root folder
tar file and extract it in specified folder, the problem is that i`m getting error(not found in archive
tar: Exiting with failure status due to previous errors), Im new to scripting ...

The tar is under the root

this is my script

#!/bin/bash
mkdir aa_tmp
mkdir bb_myBP

tar -xvf /home/i079900/aiab-cdi-ui-assembly.tar /home/i079900/bb_myBP
echo "success"


I want that after the folder bb_myBP is created to extract this file in the bb_myBP
all folder and assets are under /home/i079900, any idea what I miss here?

the tar file is located under my user ...

Answer

So you want to extract the files to he newly created directory bb_myBp?

tar command needs a -C argument to determine which directory to extract.

#!/bin/bash
mkdir aa_tmp
mkdir bb_myBP

tar -xvf /home/i079900/aiab-cdi-ui-assembly.tar -C 
/home/i079900/bb_myBP
echo "success"