Index
Subject
: Re: LUG: seeking elegant solution
From
: Stephen Roller <scroller@ncsu.[redacted]>
Date
: Wed, 16 Nov 2011 19:31:21 -0600
Parent
Slight modification from Alex's post:
for file in $(ls --color=none 2/); do cp 1/$file 2/$file; done
The --color=none might not be necessary, but it was for me. The $ in
front of the file inside the loop is definitely necessary.
I would make backups of both directories before you do something you can't undo.
On Wed, Nov 16, 2011 at 7:01 PM, Alex Ray <alexjray.ncsu@gmail.[redacted]> wrote:
> Checkout bash for loops. I suspect you want something of the form :
>
> for file in $(ls 2/);
> do
> cp 1/file 2/file
> done
>
> Cheers,
> Alex
>
> On Nov 16, 2011 7:57 PM, "Aaron Oakes" <ajoakes@ncsu.[redacted]> wrote:
>>
>> I have what I think should be a pretty easy problem to solve.
>>
>> In directory 1 are files 1,2,3,4,5.
>> Directory 2 contains files 2 and 4.
>>
>> All the files are jpeg images and the files in directory 2 have been
>> modified more recently than those in directory 1. Â I want to copy
>> files 2 and 4 from directory 1 to directory 2.
>>
>> Based on my limited past experience with linux I have a hunch that
>> there is a very elegant and efficient way to accomplish this task.
>>
>> Any thoughts?
>>
>> Thanks in advance.
>>
>> Cheers,
>> Aaron
>>
>
Replies
: