Results 1 to 6 of 6
I have 4 lines of code where I tar the doc files and then extract to some other location.
Code:
cd ${INSTALLER_BUILD_ROOT}/doc/
tar cvf build_doc.tar *
cd $DOC_ROOT/doc
tar xvf ...
- 11-04-2008 #1Just Joined!
- Join Date
- Apr 2007
- Posts
- 59
tar and extract in a single line
I have 4 lines of code where I tar the doc files and then extract to some other location.
Can I optimize it and reduce to a single line?Code:cd ${INSTALLER_BUILD_ROOT}/doc/ tar cvf build_doc.tar * cd $DOC_ROOT/doc tar xvf ${INSTALLER_BUILD_ROOT}/doc/build_doc.tar
- 11-04-2008 #2
Do you want to end up with an additional archive in $DOC_ROOT or do you merely want to copy the files?
cp ${INSTALLER_BUILD_ROOT}/doc/* $DOC_ROOT/doc/Debian GNU/Linux -- You know you want it.
- 11-04-2008 #3Just Joined!
- Join Date
- Apr 2007
- Posts
- 59
Actually, I want to just copy the files. But I can't use cp command because I'm doing this copy on the network drive location which starts with //, and cp command ignores the Case. ( for ex: it will copy the Hello as hello, which I do not want)
I want to use tar only.
- 11-04-2008 #4Linux Newbie
- Join Date
- Jul 2008
- Posts
- 181
Use the pipe. That's what it's there for.
- 11-04-2008 #5Linux User
- Join Date
- Jun 2007
- Posts
- 318
Code:# cd ${INSTALLER_BUILD_ROOT}/doc/; tar cf - . | (cd $DOC_ROOT/doc; tar xpf -)
- 11-05-2008 #6Just Joined!
- Join Date
- Apr 2007
- Posts
- 59
Thanks, this is what I was looking for!


Reply With Quote