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 7572633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:58:27+00:00 2026-05-30T15:58:27+00:00

Should be an easy question for the gurus here, though it’s hard to explain

  • 0

Should be an easy question for the gurus here, though it’s hard to explain it in text so hopefully this is clear. I’ve got two directories on a box with some flavor of unix on it. I’ve got a script that I want to use to move all the files and directories from one location to another.

First, an example of how the directories look:

Directory A: final/results/2012/2012-02/2012-02-25/name/files

Directory B: test/results/2012/2012-02/2012-02-24/name/files

So you see they’re very similar. What I want to do is move everything from the Directory B 2012 directory, recursively, to the same level of Directory A. So you’d end up with:

someproject/results/2012/2012-02/2012-02-25/name/files

someproject/results/2012/2012-02/2012-02-24/name/files

etc.

I want this script to be future proof though, meaning I don’t want the 2012 hardcoded. Also, towards the end of a month you will potentially have data from two different months and both need to be copied into the 2012 directory. So here is the command I used in the shell script file:

CONS="/someproject";
ROOT="/test";

/bin/cp -r ${ROOT}/results/* ${CONS}/results/*

but this resulted in:

/final/results/2012/2012-02/2012-02-25/name/files

and

/final/results/2012/2012/2012-02/2012-02-24/name/files

So as I hope is clear, it started a level below where I wanted it too. Can anyone fill me in on what I’m doing wrong, if they can understand what I’m even trying to explain. My apologies if it’s not clear. I’m sure this is a fairly simple fix but I’m not sure what to do. Shell scripting is not a strong point of mine.

  • 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-30T15:58:28+00:00Added an answer on May 30, 2026 at 3:58 pm

    One poster suggests rsync, which is overkill.

    cp -rp will work fine. if you want to move the files, just mv the directory — it and everything under it will move too.

    The only real problem here is the use of terminating *’s in the command line in the original script. You don’t need the *, you’re just trying to pass directories to the cp command, you aren’t trying to pass it the names of all the files already in the source (and more importantly, the destination).

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

Sidebar

Related Questions

This should be an easy question. I have two url patterns in Django: url(r'^wiki/page/(?P<page_title>.*)',
This should be an easy question hopefully but as a rookie I don't know
Hopefully this should be an easy question. In Java I think it's compareTo() .
So this should be a real easy question but I can't seem to find
This should a quick question for some easy rep. I'm doing some PHP Website
I have what should be an easy question for you today. I have two
A bit of a Ruby newbie here - should be an easy question: I
I am just starting on MVC so this should be an easy question to
This should be an easy question I figure, but I hadn't found this answered
This should be an easy question for many of you! Background: I am having

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.