0

I have a C file created :

 (
cat <<'End'
ifdef
 ...
 else
 ...
 endif
EOF) > $CFILE

and I want to move this new created c file to particular location in Tar file already generated.

tar -rvf $TARFILE "magically move CFILE to /foo/bar in tar file"

1 Answer 1

3

With GNU tar, by using --transform and specifying a sed-style substitution:

$ tar -rvf test.tar --transform 's#^#/here/it/is/#' .profile
.profile

$ tar tf test.tar
tar: Removing leading `/' from member names
/here/it/is/.profile

With BSD tar, by using -s in a similar (but not identical) way:

$ tar -rvf test.tar -s '#^#/here/it/is/#' .profile
/here/it/is/.profile

$ tar tf test.tar
tar: Removing leading / from absolute path names in the archive
here/it/is/.profile

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .