Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is it possible to create a target directory, similar in nature to the mkdir -p switch, where I can define a non-existent target directory within my tar command, and tar will create the directory for me?

I know I can redirct the output to a directory using tar -C /target/dir, but this doesn't work if the target directory is non-existent.

share|improve this question
2  
If it isn't possible, you could always create a shell alias. –  MaxMackie Nov 25 '11 at 4:02
add comment

1 Answer

up vote 4 down vote accepted
mkdir -p /target/dir && tar -C /target/dir
share|improve this answer
    
@V for V - that's what I've been using; I was thinking there might be something OOTB. –  wulfgar.pro Nov 25 '11 at 5:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.