You can – but it takes a little trickery, because most Linux OneDrive clients were designed to mirror a whole folder tree, not “just this one file.” Below are three different approaches:
Using abraunegg’s onedrive client with a sync_list
# tell the client where your local OneDrive folder is
sync_dir = "~/OneDrive"
# point it at a text-file list of exactly what you want to sync
sync_list = "~/.config/onedrive/sync_list.txt"
In ~/.config/onedrive/sync_list.txt put the relative path(s) you want to sync. For example, to sync only~/OneDrive/project/notes.md:
code
project/notes.md
Run:
bash
onedrive --synchronize --resync
The client will look at sync_list.txt and upload/download only those entries.
Tip: if you want sub-folders, just add more lines:
If you’d rather keep your usual folder tree but tell the client “ignore everything except X,” you can use the skip-patterns:
ini
# ~/.config/onedrive/config
sync_dir = "~/OneDrive"
# skip all files
skip_file = ".*"
# skip all dirs except the one you want
# in bash regex form, so we “negative-lookahead” our target path:
skip_dir = "^(?!project$).*$"
This effectively tells the client:
“Don’t touch any file” (skip_file)
“Don’t descend into any directory except project” (skip_dir)
Inside project you can then add more skip rules (or not) to whittle it down to your single file.
—---
3) One-off sync with rclone
If you only need to push/pull one file every now and then, you might find rclone simpler:
rclone config → set up a OneDrive remote called onedrive:
You won’t get automatic background monitoring, but you will get a single-file sync.
—---
Any of these patterns will let you treat one file as your “sync target.” If you let me know which client you’re using (or if you need inotify-style automatic updates), I can tailor the instructions further! 😊