X

使用 CLI 操作 Google Drive

Google Drive 可以存資料,但是於 Linux 的 CLI 要存取,有沒有工具可以操作使用呢?

使用 CLI 操作 Google Drive

有人使用 Golang 寫了一套 Google Drive CLI Client 的工具,詳見:

Gdrive cli client 安裝方式

  1. 於上述的網頁 下載 gdrive-linux-x64 2.1.0 Linux 64-bit
  2. mv gdrive-linux-x64 /usr/local/bin/gdrive
  3. chmod +x /usr/local/bin/gdrive
  4. gdrive list # 會出現下述需要授權允許
    Authentication needed
    Go to the following url in your browser:
    https://accounts.google.com/o/oauth2/auth?access_type=offline&...
  5. 點選後,就會拿到授權 ID,再來貼上去就可以開始操作了~

註1:若有安裝 Go 環境,可以用更簡便的安裝方式:go get github.com/prasmussen/gdrive 即可。

註2:若太久沒執行,被說 oAuth 錯誤的話,刪掉憑證在重新認證一次即可。(rm ~/.gdrive/token_v2.json)

gdirve 常用命令

  • gdrive [global] list [options]:List files
  • gdrive [global] download [options]:Download file or directory
  • gdrive [global] upload --recursive [options]:Upload file or directory
  • gdrive [global] upload - [options]:Upload file from stdin
  • gdrive [global] update [options]:Update file, this creates a new revision of the file
  • gdrive [global] mkdir [options]:Create directory
  • gdrive [global] delete [options]:Delete file or directory
  • gdrive [global] sync list [options]:List all syncable directories on drive
  • gdrive [global] sync content [options]:List content of syncable directory
  • gdrive [global] sync download [options]:Sync drive directory to local directory
  • gdrive [global] sync upload [options]:Sync local directory to drive
Tsung: 對新奇的事物都很有興趣, 喜歡簡單的東西, 過簡單的生活.
Related Post