Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6065519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:23:59+00:00 2026-05-23T09:23:59+00:00

I have a list of file paths in a variable. I’d like to copy

  • 0

I have a list of file paths in a variable. I’d like to copy each file in this list to a new location. The problem is that I’m very new to makefiles and I’m struggling to get anything working. My attempt has culminated at the following, although not working (and probably totally wrong) I hope it illustrates what I’m trying to do.

FILES = a/b/file c/d/file e/.../file etc...
copyfiles:
       for file in $(FILES); do \
           cp $$file newDir/$(notdir $$file);  \
       done
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:24:00+00:00Added an answer on May 23, 2026 at 9:24 am

    You could do

    FILES = a/b/file c/d/file e/.../file etc...
    copyfiles:
        cp $(FILES) newDir
    

    I tried it, and it works.

    Remember, globbing is done by the shell, not by the commands. cp takes a list of files as arguments, and copies all of them to the location specified by the last argument. When you type cp *.cpp all the cp program sees as its arguments are the files in the current directory that end in .cpp.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a file that looks like this: ... %ldirs (list of line-separated directories)
I have a file that essentially a list of XPaths like so: /Options/File[1]/Settings[1]/Type[1] /Options/File[1]/Settings[1]/Path[1]
I have a large list of file names that are illegal, I want to
I have a list URLs in a file called urls.txt . Each line contains
I have a list of countries in this format in an external file: <?
I have a variable with a list of prerequisites in varying directories, each specified
I have a script that I've put together that should copy the list of
I have a list of file input boxes and I want to know if
I have a list of timestamps in a text file. I want to figure
I have a list Dogs in a text file with the following format: id:fatherid:motherid:born:owner:breed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.