Getting bash: $: command not found

Good luck as I've asked the same question a few times now and you won't share any examples/output like I've asked.

rclone tree /home/user01/test
/
├── 01
│   ├── blahcache
│   │   └── blahcache.01.txt
│   ├── cache
│   │   └── cache.01.txt
│   └── file.01.txt
└── 02
    ├── cache
    │   └── cache.02.txt
    ├── cacheblah
    │   └── cacheblah.02.txt
    └── file.02.txt

6 directories, 6 files

rclone tree /home/user01/test --exclude=cache/
/
├── 01
│   ├── blahcache
│   │   └── blahcache.01.txt
│   └── file.01.txt
└── 02
    ├── cacheblah
    │   └── cacheblah.02.txt
    └── file.02.txt

4 directories, 4 files
rclone ls /home/user01/test --exclude=cache/
        0 01/file.01.txt
        0 01/blahcache/blahcache.01.txt
        0 02/file.02.txt
        0 02/cacheblah/cacheblah.02.txt

I didn't put directory output because i don't get how this is important. I want to exclude directories by name, not by location. But if you insist here is few cache directories:

/home/user/.config/Mailspring/Cache
/home/user/.config/Portmaster/Cache
/home/user/.config/joplin-desktop/cache
/home/user/.config/tutanota-desktop/Cache

It allows for me to see exactly what you want and I'm helping you and I asked a number of times so I think it's important as it allows me to make a use case based on your specific situation that I can test with your specific output and I don't have to guess/assume as if I'm not sure, I waste my time and your time as I value both your time and my time and try to make the best use of both.

felix@gemini:~/test$ rclone ls /home/felix/test
        0 notexcluded/test
        0 Mailspring/Cache/test
        0 joplin-desktop/cache/testtwo
        0 Mailspring/Cache/test


felix@gemini:~/test$ rclone ls /home/felix/test  --exclude '**/Cache/**' --exclude '/**/cache/**'
        0 notexcluded/test

hi,

  • i was trying to replicate you example, not sure how there are two Mailspring/Cache/test?
  • is there a practical difference between these two, as they give the same output
    --exclude='cache/' --exclude='Cache/'
    and
    --exclude '**/Cache/**' --exclude '/**/cache/**'
rclone ls /home/user01/test
        0 notexcluded/test
        0 Mailspring/Cache/test
        0 joplin-desktop/cache/testtwo

rclone ls /home/user01/test --exclude=cache/ --exclude=Cache/
     0 notexcluded/test

rclone ls /home/user01/test --exclude '**/Cache/**' --exclude '/**/cache/**'
     0 notexcluded/test

Just depends on how your brain wants to process a filter I suppose. If you dump them:

2021/12/07 11:29:49 DEBUG : Setting --config "/opt/rclone/rclone.conf" from environment variable RCLONE_CONFIG="/opt/rclone/rclone.conf"
--- start filters ---
--- File filter rules ---
- (^|/)cache/.*$
- (^|/)Cache/.*$
--- Directory filter rules ---
- (^|/)cache/.*$
- (^|/)Cache/.*$
--- end filters ---

and

felix@gemini:~/test$ rclone ls /home/felix/test --exclude '**/Cache/**' --exclude '/**/cache/**' -vvv --dump filters
2021/12/07 11:30:10 DEBUG : Setting --config "/opt/rclone/rclone.conf" from environment variable RCLONE_CONFIG="/opt/rclone/rclone.conf"
--- start filters ---
--- File filter rules ---
- (^|/).*/Cache/.*$
- ^.*/cache/.*$
--- Directory filter rules ---
- (^|/).*/Cache/.*$
- ^.*/cache/.*$
--- end filters ---

This part would be key in not using **:

If the filter pattern starts with a / then it only matches at the top level of the directory tree, relative to the root of the remote (not necessarily the root of the drive). If it does not start with / then it is matched starting at the end of the path/file name but it only matches a complete path element - it must match from a / separator or the beginning of the path/file.

So like this doesn't work:

felix@gemini:~/test$ rclone ls /home/felix/test --exclude=/cache/ --exclude=/Cache/
        0 notexcluded/test
        0 Mailspring/Cache/test
        0 joplin-desktop/cache/testtwo

So I'd argue mine is more explicit with what I want to do as I want to match anything but with that / and not using / setup, yours works as well.

Maybe i am not explaining well what i am trying to do. English is not my native language.

I run this command, and it excluded some cache directories, but some it didn't exclude, like ~/.cache directory:

rclone ls /home/user/ --exclude '**/Cache/**' --exclude '/**/cache/**'

That's because ".cache" was not in any of your examples which is why I repeatedly asked to see your output so we don't have to guess at your use case.

Now, you want a file that contains the word ".cache" in it.

So a filter for that looks like.

felix@gemini:~/test$ rclone ls /home/felix/test --exclude '**.cache**/**'
        0 notexcluded/test
        0 Mailspring/Cache/test
        0 joplin-desktop/cache/testtwo
felix@gemini:~/test$ rclone ls /home/felix/test
        0 notexcluded/test
        0 joplin-desktop/cache/testtwo
        0 Mailspring/Cache/test
        0 .cache/blah

Using '**.cache**/**' excluded ~/.cache. Thanks!

It didn't work before because you cut'n'pasted a sample output that included a command line such as

 $ rclone ....

including the $ sign, and so got your original error message.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.