tar how to rename

| 分类 Utility  | 标签 tar 

1 Use -C and –strip-components (See man tar).

Example:

mkdir FOLDER
# for remote tar file
curl -L ’remote_tar_file' | tar -xz - -C FOLDER --strip-components=1

# for local tar file
tar -xz FILENAME -C FOLDER --strip-components=1

2 Use --transform

You can also use the –transform option for a bit more flexibility. It accepts any sed replacement (s) operation.

For example, this is how I extract a Linux tarball to a new directory so I can apply a patch:

tar -xjf linux-2.6.38.tar.bz2 --transform 's/linux-2.6.38/linux-2.6.38.1/'

上一篇     下一篇