GNU/Linux >> Linux の 問題 >  >> Linux

LinuxコマンドラインからのGoogleドライブの使用

GDrive

Gdriveは、Googleドライブ上のファイルを管理、アップロード、ダウンロード、削除、共有するコマンドラインツールです。ツールは、Github(https://github.com/prasmussen/gdrive)からダウンロードできます。

残念ながら、ファイルの同期はサポートされていません。

インストール

githubWebサイトからバイナリパッケージをダウンロードしてインストールします

sudo mv drive /usr/local/bin

または、ソースコードからインストールすることもできます。次に、ドライブを実行するだけで、OAuthを使用して認証するURLが提供されます。

使用法

drive [global options] <verb> [verb options]

オプション

Global options:
        -a, --advanced Advanced Mode -- lets you specify your own oauth client id and secret on setup
        -c, --config   Set application path where config and token is stored. Defaults to ~/.gdrive
        -v, --version  Print version
        -h, --help     Show this help

Verbs:
    delete:
        -i, --id       File Id (*)
    download:
        -i, --id       File Id (*)
        -s, --stdout   Write file content to stdout
            --pop      Download latest file, and remove it from google drive
    folder:
        -t, --title    Folder to create (*)
        -p, --parent   Parent Id of the folder
            --share    Share created folder
    info:
        -i, --id       File Id (*)
    list:
        -m, --max      Max results
        -t, --title    Title filter
        -q, --query    Query (see https://developers.google.com/drive/search-parameters)
        -s, --shared   Show shared status (Note: this will generate 1 http req per file)
        -n, --noheader Do not show the header
    share:
        -i, --id       File Id (*)
    unshare:
        -i, --id       File Id (*)
    upload:
        -f, --file     File or directory to upload (*)
        -s, --stdin    Use stdin as file content (*)
        -t, --title    Title to give uploaded file. Defaults to filename
        -p, --parent   Parent Id of the file
            --share    Share uploaded file
    url:
        -i, --id       File Id (*)
        -p, --preview  Generate preview url (default)
        -d, --download Generate download url

ファイルの一覧表示

$ drive list
Id                             Title                     Size     Created
0B3X9GlR6EmbnenBYSFI4MzN0d2M   drive-freebsd-amd64       5 MB     2013-01-01 21:57:01
0B3X9GlR6EmbnOVRQN0t6RkxVQk0   drive-windows-amd64.exe   5 MB     2013-01-01 21:56:41
0B3X9GlR6Embnc1BtVVU1ZHp2UjQ   drive-linux-arm           4 MB     2013-01-01 21:57:23
0B3X9GlR6EmbnU0ZnbGV4dlk1T00   drive-linux-amd64         5 MB     2013-01-01 21:55:06
0B3X9GlR6EmbncTk1TXlMdjd1ODQ   drive-darwin-amd64        5 MB     2013-01-01 21:53:34

ファイルまたはディレクトリをアップロード

$ drive upload --file drive-linux-amd64
Id: 0B3X9GlR6EmbnU0ZnbGV4dlk1T00
Title: drive-linux-amd64
Size: 5 MB
Created: 2013-01-01 21:55:06
Modified: 2013-01-01 21:55:06
Owner: Petter Rasmussen
Md5sum: 334ad48f6e64646071f302275ce19a94
Shared: False
Uploaded 'drive-linux-amd64' at 510 KB/s, total 5 MB

ファイルのダウンロード

$ drive download --id 0B3X9GlR6EmbnenBYSFI4MzN0d2M
Downloaded 'drive-freebsd-amd64' at 2 MB/s, total 5 MB

ファイルを共有する

$ drive share --id 0B3X9GlR6EmbnOVRQN0t6RkxVQk0
File 'drive-windows-amd64.exe' is now readable by everyone @ https://drive.google.com/uc?id=0B3X9GlR6EmbnOVRQN0t6RkxVQk0

コンテンツをドライブに直接パイプする

$ echo "Hello World" | drive upload --stdin --title hello.txt
Id: 0B3X9GlR6EmbnVHlHZWZCZVJ4eGs
Title: hello.txt
Size: 12 B
Created: 2013-01-01 22:05:44
Modified: 2013-01-01 22:05:43
Owner: Petter Rasmussen
Md5sum: e59ff97941044f85df5297e1c302d260
Shared: False
Uploaded 'hello.txt' at 6 B/s, total 12 B

ファイルをstdoutに印刷

$ drive download --stdout --id 0B3X9GlR6EmbnVHlHZWZCZVJ4eGs
Hello World

ファイル情報を取得

$ drive info --id 0B3X9GlR6EmbnVHlHZWZCZVJ4eGs
Id: 0B3X9GlR6EmbnVHlHZWZCZVJ4eGs
Title: hello.txt
Size: 12 B
Created: 2013-01-01 22:05:44
Modified: 2013-01-01 22:05:43
Owner: Petter Rasmussen
Md5sum: e59ff97941044f85df5297e1c302d260
Shared: False

ファイルへのURLを取得

$ drive url --id 0B3X9GlR6EmbnVHlHZWZCZVJ4eGs
https://drive.google.com/uc?id=0B3X9GlR6EmbnVHlHZWZCZVJ4eGs

Linux
  1. Linuxコマンドラインでのtcpdumpの使用の概要

  2. Linuxコマンドラインで力を使用する

  3. Stratisを使用してコマンドラインからLinuxストレージを管理する

  1. コマンドラインを使用してLinuxでtar.gzファイルを抽出する方法

  2. Linux でコマンドラインを使用して任意のファイルをダウンロードするための 4 つのツール

  3. inode 番号を使用して Linux でファイルを削除する

  1. コマンドラインからリモートでLinuxワークスペースを構成する

  2. LinuxコマンドラインからのI/Oレポート

  3. Linuxのコマンドラインを使用してファイルを作成する