簡介
Gdrive,Linux下上傳、下載Google Drive文件的一款CLI工具,安裝簡單、使用方便。
安裝
centos 7下測試通過。
1、安裝
Linux 32-bit
1 2 3 4 |
rm -f /usr/sbin/gdrive wget -O gdrive https://docs.google.com/uc?id=0B3X9GlR6EmbnLV92dHBpTkFhTEU mv gdrive /usr/sbin/gdrive chmod 755 /usr/sbin/gdrive |
Linux 64-bit
1 2 3 4 |
rm -f /usr/sbin/gdrive wget -O gdrive https://docs.google.com/uc?id=0B3X9GlR6EmbnQ0FtZmJJUXEyRTA mv gdrive /usr/sbin/gdrive chmod 755 /usr/sbin/gdrive |
2、授權
1 |
gdrive about |
然後會出現一串網址並詢問驗證碼。
請輸入圖片描述
將地址粘貼到瀏覽器並登陸賬號,會返回一串代碼。
請輸入圖片描述
將代碼粘貼到SSH下,然後會返回你的賬戶信息。
請輸入圖片描述
gdrive程序會自動將你的token保存在用戶目錄下的.gdrive目錄中,所以如果不需要了記得把這個文件刪掉。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
server: ~ >gdrive help gdrive usage: gdrive [global] list [options] List files gdrive [global] download [options] <fileId> Download file or directory gdrive [global] download query [options] <query> Download all files and directories matching query gdrive [global] upload [options] <path> Upload file or directory gdrive [global] upload - [options] <name> Upload file from stdin gdrive [global] update [options] <fileId> <path> Update file, this creates a new revision of the file gdrive [global] info [options] <fileId> Show file info gdrive [global] mkdir [options] <name> Create directory gdrive [global] share [options] <fileId> Share file or directory gdrive [global] share list <fileId> List files permissions gdrive [global] share revoke <fileId> <permissionId> Revoke permission gdrive [global] delete [options] <fileId> Delete file or directory gdrive [global] sync list [options] List all syncable directories on drive gdrive [global] sync content [options] <fileId> List content of syncable directory gdrive [global] sync download [options] <fileId> <path> Sync drive directory to local directory gdrive [global] sync upload [options] <path> <fileId> Sync local directory to drive gdrive [global] changes [options] List file changes gdrive [global] revision list [options] <fileId> List file revisions gdrive [global] revision download [options] <fileId> <revId> Download revision gdrive [global] revision delete <fileId> <revId> Delete file revision gdrive [global] import [options] <path> Upload and convert file to a google document, see 'about import' for available conversions gdrive [global] export [options] <fileId> Export a google document gdrive [global] about [options] Google drive metadata, quota usage gdrive [global] about import Show supported import formats gdrive [global] about export Show supported export formats gdrive version Print application version gdrive help Print help gdrive help <command> Print command help gdrive help <command> <subcommand> Print subcommand help |
1、列出Google Drive根目錄下文件、文件夾
1 |
gdrive list |
2、下載Google Drive根目錄下文件到本地(xxxx為文件名)
1 |
gdrive download xxxx |
3、下載Google Drive根目錄下文件夾到本地(xxx為文件夾名)
1 |
gdrive download xxxx |
4、把本地文件上傳到Google Drive根目錄下(xxxx為文件名)
1 |
gdrive upload xxxx |
5、在Google Drive根目錄下創建文件夾(xxx為文件夾名)
1 |
gdrive mkdir xxx |