How to sync Google Drive subfolder to local PC runing Linux

Hi guys,

I am trying to sync a Google Drive subfolder called !_Ebooks to my laptop running Linux Ubuntu. I have already asked how to do it directly odrive guys via facebook and I got some general one liner which does not work or I can’t figure out how to adjust it to my specific scenario.
I have synced the main GDrive folder and it’s showing local placeholders with .cloud and .cloudf extensions but how do I get the whole subfolder with all files in it?

here is the one liner “exec 6>&1;output=“go”; while [ “$output” ]; do output=$(find “$HOME/odrive-agent-mount/Dropbox/” -name “.cloud” -exec python “$HOME/.odrive-agent/bin/” sync “{}” ;|tee /dev/fd/6); done”


Hi @djxpace,
You will need to change the “$HOME/odrive-agent-mount/Dropbox/” part to the folder you want to sync. I’m guessing that is something like “$HOME/odrive-agent-mount/Google Drive/!_Ebooks”

Hi Tony,

thank you for the reply. That’s exactly what I have tried and I got an error, that’s why I have created this thread.
here is the error including the one liner:
$ exec 6>&1;output=“go”; while [ “$output” ]; do output=$(find “$HOME/odrive-agent-mount/Google Drive/!_Ebooks” -name “.cloud” -exec python “$HOME/.odrive-agent/bin/” sync “{}” ;|tee /dev/fd/6); done
bash: !_Ebooks: event not found

the placeholder for !_Ebooks is there “!_Ebooks.cloudf” so not sure what’s happening.


The ! is used for history expansion in bash, so bash is going to barf on that character, thinking that you are referencing a historic command. You can turn off history expansion with:
set +H

and then running your sync command. If you want to turn history expansion back on, it’s
set -H

Thanks again, but where and how do I run the set +H parameter because when I fit it in the one liner, same error comes up .

You can just run it as its own command, separately, then run the sync command after.

Tony, I’m sure you know what you are talking about but in my case I am just guessing.
I have ran this command:

python "$HOME/.odrive-agent/bin/" set +H

because that’s what I have assumed as it’s own command ran separately but unfortunately I am getting error:

usage: [-h]{authenticate,mount,unmount,backup,removebackup,sync,stream,refresh,unsync,xlthreshold,syncstate,status,deauthorize,emptytrash,shutdown} error: argument command: invalid choice: 'set' (choose from u'authenticate', u'mount', u'unmount', u'backup', u'removebackup', u'sync', u'stream', u'refresh', u'unsync', u'xlthreshold', u'syncstate', u'status', u'deauthorize', u'emptytrash', u'shutdown')

and as the error states there is no such an option “set”

Can you please type the command for me as honestly I am really guessing. I’m not new to Linux at all but I am very new to odrive.

Thank you very much

Hi @djxpace,
This is just part of bash: (look for -H)

So you would just run set +H on a line, by itself. In other words, in the terminal, type:
set +H
and then hit enter.

Hi Tony,

Much appreciate your help. I was not here all this time so I didn’t try until now. After the one liner now I have no error message or anything but I have used the full name !_Ebboks.cloudf as without the cloudf I get the same error that it can’t be found. Not sure what I’m doing wrong but obviously something is not playing nice.
Any other tips?
thanks a bunch

Hi @djxpace,
I would need to see the terminal output to see what commands you are using. What would be best is to perform these steps:

  1. ls -al "$HOME/odrive-agent-mount/Google Drive"
  2. set +H
  3. exec 6>&1;output="go"; while [ "$output" ]; do output=$(find "$HOME/odrive-agent-mount/Google Drive/!_Ebooks" -name ".cloud" -exec python "$HOME/.odrive-agent/bin/" sync "{}" \;|tee /dev/fd/6); done

Hi Tony,
have done exactly as you said. here is the list of commands and their output so you can see what happened in the terminal. see the file


odrive.txt (9.8 KB)

Ahh. Okay you will first need to sync the !_Ebooks.cloudf folder so that it is expanded into a “normal” folder, then run the sync command. So like this:

  1. set +H
  2. python "$HOME/.odrive-agent/bin/" sync "$HOME/odrive-agent-mount/Google Drive/!_Ebooks.cloudf"
  3. exec 6>&1;output="go"; while [ "$output" ]; do output=$(find "$HOME/odrive-agent-mount/Google Drive/!_Ebooks" -name ".cloud" -exec python "$HOME/.odrive-agent/bin/" sync "{}" \;|tee /dev/fd/6); done

excellent, thank you, I had some progress and the folder !_Eboks looks like a folder now but anything in the folder is not synced even after step 3 you have provided. Step 3 actually has no output whatsoever. I have tried manually sync one subfolder but any files in it have not been synced. In !_Ebooks folder I have many subfolders and files in them. How do I do that as a batch? Or do I need to sync each folder and file separately? Thanks again

I have successfuly synced files in one subfolder one by one, but that’s not what I’m after I need to sync the whole folder !_Ebooks as it is in one go, not one by one as there are hundreds of files and many many subfolders. Is there a way? Thank you.

I just realized what the problem was here. The asterisk got dropped somehow as we were copy and pasting these commands. So, this command will sync all files in a folder:

exec 6>&1;output="go"; while [ "$output" ]; do output=$(find "$HOME/odrive-agent-mount/Google Drive/!_Ebooks" -name "*.cloud" -exec python "$HOME/.odrive-agent/bin/" sync "{}" \;|tee /dev/fd/6); done

This command will sync all files and folders in a specified folder (what you want to do):

exec 6>&1;output="go"; while [ "$output" ]; do output=$(find "$HOME/odrive-agent-mount/Google Drive/!_Ebooks" -name "*.cloud*" -exec python "$HOME/.odrive-agent/bin/" sync "{}" \;|tee /dev/fd/6); done

You are the champ, thank you so much, I knew there was not something right and I started to play with the commands but I wasn’t sure what it was.
Last question, everytime I upload, erase, edit a file or folder do I need to run this command or something else?
Thanks a lot

As long as the agent is running it will pick up and sync any local changes. On Linux the pick-up time is not as fast as on Windows and Mac. You can speed the detection up by issuing a “refresh” command on the folder where the changes were made. So, if you made a change in !_Ebooks you would use this command:

python "$HOME/.odrive-agent/bin/" refresh "$HOME/odrive-agent-mount/Google Drive/!_Ebooks"

If you delete a file, it will be held in the odrive trash until you empty it. More on that here:

To view what is in the trash, you can use this command:
python "$HOME/.odrive-agent/bin/" status --trash

To empty the trash:
python "$HOME/.odrive-agent/bin/" emptytrash