I have a locally-hosted server, and am attempting to download all files to my remote Ubuntu-based machine via wget. I need to download all files from my HTTP server in a single directory, ensuring that everything apart from files with a suffix of "_test" is obtained - so in other words, I need to make sure that any file with that suffix isn't grabbed. I've tried the following command:

wget -r http://my-server-ip/data -R '*_test'

The above command results in wget fetching everything from the server - including files with the "_test" suffix. I realise that multiple examples of how to use this command correctly exist, but none appear to suit my use case. I should also note that I'm using the bash shell.

  • 1
    Do you have local files that match *_test? In this case the shell would replace *_test with the list of matching files. You should quote the pattern: wget -r http://my-server-ip/data -R "*_test", see gnu.org/software/wget/manual/html_node/…
    – Bodo
    Dec 6, 2019 at 11:36
  • @Bodo - Thank you for the suggestion. I don't have any local files with this suffix - when testing by adding quotation marks around the wildcard, this unfortunately still downloads all files (including the ones suffixed with "test").
    – elliott94
    Dec 6, 2019 at 12:37
  • Elliott94 per your comment I've added quotes to your command so that others don't sidetrack on that. Dec 6, 2019 at 14:20
  • Please move the -R '*_test' earlier in the command, per documentation that states wget [option]... [URL]..., so it's wget -r -R '*_test' http://my-server-ip/data and see if that helps. Dec 6, 2019 at 14:21
  • Please copy&paste a few real example file names to your question, both wanted and unwanted files.
    – Bodo
    Dec 6, 2019 at 14:25

1 Answer 1


Thank you everyone for your thoughts. In the end, the following command worked for me - this is the case when I have multiple files that I don't wish to grab, all having a suffix of "_test.sh":

wget -r http://my-server-ip/ -R "*_test.sh"

I also forgot that this particular folder contained files with the same suffix - but several also had an upper-case "T" at the start of "Test" - so, this command ensured that both cases were covered:

wget -r http://my-server-ip/ -R "*_test.sh" -R "*_Test.sh"
  • Can you combine the patterns, using '*_[Tt]est.sh'? Dec 10, 2019 at 9:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .