tl;dr
- フォルダごと圧縮する
tar cfvz hoge.tar.gz hoge/
- これを解凍する
tar xfvz hoge.tar.gz
圧縮ファイルのファイル名を取得する
gunzip -c hoge.tar.gz | tar tvf -
ファイルが大量にある場合は grep で絞り込む
$ gunzip -c sirokuro-dev6.tar.gz | tar tvf - | grep tsx
-rw-r--r-- 0 c22 staff 1999 8 14 13:46 sirokuro-dev6/src/pages/index.tsx
-rw-r--r-- 0 c22 staff 3700 7 15 09:51 sirokuro-dev6/src/pages/auth.tsx
-rw-r--r-- 0 c22 staff 19805 8 16 01:22 sirokuro-dev6/src/pages/post.tsx
-rw-r--r-- 0 c22 staff 4829 8 14 14:17 sirokuro-dev6/src/pages/sirokuro.tsx
-rw-r--r-- 0 c22 staff 11858 8 1 10:10 sirokuro-dev6/src/pages/profile.tsx
-rw-r--r-- 0 c22 staff 1851 7 8 12:18 sirokuro-dev6/src/pages/_app.tsx
-rw-r--r-- 0 c22 staff 5126 7 15 15:15 sirokuro-dev6/src/pages/sirokurod/[id].tsx
-rw-r--r-- 0 c22 staff 4564 8 4 10:29 sirokuro-dev6/src/components/Banner.tsx
-rw-r--r-- 0 c22 staff 6984 8 14 22:42 sirokuro-dev6/src/components/Appdrawer.tsx
-rw-r--r-- 0 c22 staff 436 7 11 16:32 sirokuro-dev6/src/components/Footer.tsx
-rw-r--r-- 0 c22 staff 160 6 14 12:15 sirokuro-dev6/src/components/Spinner.tsx
$
圧縮ファイルの特定のファイルのなかみを確認したい
$ tar -zxOf sirokuro-dev6.tar.gz sirokuro-dev6/src/components/Footer.tsx
import React, { FC } from "react";
import styles from "./Footer.module.css";
const thisyear = new Date().getFullYear();
export const Footer: FC = () => {
return (
<>
<footer className={styles.footer}>
<a
href="https://unremoted.com"
target="_blank"
rel="noopener noreferrer"
>
Copyright © unremoted.com {thisyear}.
</a>
</footer>
</>
);
};
$
圧縮ファイルの特定のファイルを解凍したい
xxxx/xxxx.tsx を取り出す
gunzip -c archive.tar.gz | tar xvf - xxxx/xxxx.tsx