この記事を読みました.
こういう時は "--help” オプションを覚えておきましょう.
困ったら "tar --help"
”--help"を指定してtarコマンドを実行します.
$ tar --help
使用方法に関するヘルプ(簡易的なマニュアル)が表示されます.先頭を引用すると次のようになります.
使用法: tar [オプション...] [ファイル]... GNU 'tar' saves many files together into a single tape or disk archive, and can restore individual files from the archive. Examples: tar -cf archive.tar foo bar # Create archive.tar from files foo and bar. tar -tvf archive.tar # List all files in archive.tar verbosely. tar -xf archive.tar # Extract all files from archive.tar.
Examplesとして例が表示されます.
1行目.
tar -cf archive.tar foo bar # Create archive.tar from files foo and bar.
tarファイルを作るとき(圧縮するとき)は create です
オプションは"-c"です
2行目のList allは割愛.
3行目.
tar -xf archive.tar # Extract all files from archive.tar.
tarファイルを展開する時(解凍するとき)は extract です
オプションは "-x" に対応します
このように "--help” オプションだけ覚えておけば、必要なオプションがすぐにわかります。
"--help"オプションは他のコマンドでも使える
この方法はtarコマンドに限らずほぼ全てのコマンドで使えます。
lsのオプションがわからない時は
$ ls --help
zipの使い方がわからない時も
$ zip --help
です
"man tar"でマニュアルも読める
$ man tar
$ man ls
$ man zip
でマニュアルを読むともっと詳しいことがわかります。
最初のステップとして "--help" を覚える
まずは最初のステップとして、コマンドのオプションは覚えらない時は "--help" を覚えましょう