FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian User

 
 
LinkBack Thread Tools
 
Old 09-24-2011, 05:18 PM
Osamu Aoki
 
Default command to mv files & folders to dir

Hi,

On Sat, Sep 24, 2011 at 05:31:47PM +0700, Ivan Shmakov wrote:
> >>>>> Camaleón <noelamac@gmail.com> writes:
> >>>>> On Sat, 24 Sep 2011 11:40:48 +0200, Mark Panen wrote:
>
> >> Made a bit off a muck up off things when i backed up parts of my
> >> /home/mark directory to /mnt/deer
>
> >> In /mnt/deer i know have hundreds of files and folders which i
> >> rsynced on 22/09/2011.
>
> >> I need a command line option to put them all In one shot in
> >> /mnt/deer/zebra.
>
> > Not a command line but Midnight Commander is very good for such
> > day-to- day tasks.
>
> Following the suggestion of Victor Wagner (in
> news:fido7.ru.unix.linux, I believe), I've dropped
> Midnight Commander in favor of Bash something like a decade ago.
>
> I've never regret the change.
>
> Midnight Commander may simplify the simple things, but
> whatever's your experience with it, the complex tasks are often
> impossible.

??? It is possible but repeating it is a bit of hussle.

> On the contrary, Shell lets one to benefit from the
> experience, and the solutions to the simpler tasks could usually
> be re-used to solve the more complex ones.

But task described does not seem to be much of repeat action. MC can do
this by:
* Open old and new directory in each panel.
* Mark all directory then unmark new directory in the old directory panel
* press F6
==> DONE!

> Not to mention that the use of Shell keeps one's mind “in
> shape.”

Hmmm...

MC is good for interactive complex task while shell command with find
command is good for repeated complex task. Many shell scripts tends
to become very complex which requires too much time for debugging.

When there is some exclusion rule etc., most commands with rsync etc.
becomes nealy impossible to debug for people like me.

Anyway, here are typical tricks used to copy files.

http://www.debian.org/doc/manuals/debian-reference/ch10.en.html#_idioms_for_the_copy

If you combine this with find as described in the following link, it can
really do any complicated selection and copy.

http://www.debian.org/doc/manuals/debian-reference/ch10.en.html#_idioms_for_the_selection_of_files

This is good if you are making backup script for regular backups. It
can be told to pick file by date or size.... Or you can create target
directory name automatically by date. That is when you need such shell
script.

(I would not bother doing this just for simple task like what you
described. If you configure MC to display hidden files, it is very
powerful.)

Regards,

Osamu


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20110924171831.GB21979@goofy.lan">http://lists.debian.org/20110924171831.GB21979@goofy.lan
 
Old 09-24-2011, 09:59 PM
Mark Panen
 
Default command to mv files & folders to dir

On Sat, Sep 24, 2011 at 1:12 PM, Ivan Shmakov <ivan@gray.siamics.net> wrote:
>>>>>> Mark Panen <mark.panen@gmail.com> writes:
>>>>>> On Sat, Sep 24, 2011 at 11:53 AM, Ivan Shmakov wrote:
>>>>>> Mark Panen <mark.panen@gmail.com> writes:
>
> *>>> Made a bit off a muck up off things when i backed up parts of my
> *>>> /home/mark directory to /mnt/deer
>
> *>>> In /mnt/deer i know have hundreds of files and folders which i
> *>>> rsynced on 22/09/2011.
>
> *>>> I need a command line option to put them all In one shot in
> *>>> /mnt/deer/zebra.
>
> *>> It's not what I'd usually call “one shot” (= atomic), but, IIUC,
> *>> the following single command line should do it:
>
> *>> $ mkdir -pv -- /mnt/deer/zebra
> *>> * * * && find /mnt/deer/ -maxdepth 1 -mindepth 1 -not -name zebra
> *>> * * * * * * *-exec mv --target-directory=/mnt/deer/zebra -- {} +
>
> *> will this mv only the file/folders created on the 22/09/2011, i want
> *> the older files etc to stay behind.
>
> * * * *Somehow, I didn't understood that as part of the task.
>
> * * * *The -ctime constraint to find(1) may be helpful here, like:
>
> $ mkdir -pv -- /mnt/deer/zebra
> * * *&& find /mnt/deer/
> * * * * * * -maxdepth 1 -mindepth 1 -ctime -3 -not -name zebra
> * * * * * * -exec mv --target-directory=/mnt/deer/zebra -- {} +
>
> * * * *However, note that the Unix' “change time” is /not/ the file
> * * * *creation time (I know of no Unix filesystem to track the
> * * * *latter), but they /should/ coincide in this particular case.
>
> * * * *Note also that if the filesystem under /mnt is not a Unix one
> * * * *(such as VFAT), it should be checked whether the ctime is
> * * * *actually set as desired. *Like:
>
> $ LC_ALL=C stat -- /mnt/deer/foobar
>
> * * * *(Where foobar is one of the files copied 2011-09-22.) *Check if
> * * * *the Change: field is set to 2011-09-22.
>
> --
> FSF associate member #7257 * * *Join news:comp.unix.shell for pretty
> much /everything/ related to the POSIX Shell language and its variants.
>
>
> --
> To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
> Archive: http://lists.debian.org/867h4yjirp.fsf@gray.siamics.net
>
>

The command made a folder called zebra and put all the contents of
/mnt/deer in /mnt/deer/zebra so did not achieve my plan, the time
stamp is now set at 24th for all, according to $ LC_ALL=C stat --
/mnt/deer/, ctime -3 seems to be the problem.


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: CABWh29mSFZjwLOR2kuUJegZACYrbZcpQTgCsbdAciWXzdL9gS g@mail.gmail.com">http://lists.debian.org/CABWh29mSFZjwLOR2kuUJegZACYrbZcpQTgCsbdAciWXzdL9gS g@mail.gmail.com
 
Old 09-24-2011, 10:43 PM
Tom Furie
 
Default command to mv files & folders to dir

On Sat, Sep 24, 2011 at 05:00:47PM +0700, Ivan Shmakov wrote:
> >>>>> Tom Furie <tom@furie.org.uk> writes:
> > What's wrong with 'mv /mnt/deer/* /mnt/deer/zebra'? Sure, it'll
> > complain about trying to move zebra to itself, but it works.
>
> The other catch is that it won't consider the filenames with a
> leading dot, such as ‘.bashrc’.

Well, true, but there was no mention of dot files in the original
problem. Or, as has since transpired, that only some of the files in
/mnt/deer should be moved to /mnt/deer/zebra.

Ask me a question, I'll give an answer to the question. It's not my
fault that the wrong question was asked.

Cheers,
Tom

--
When neither their poverty nor their honor is touched, the majority of men
live content.
-- Niccolo Machiavelli
 
Old 09-24-2011, 11:14 PM
Mark Panen
 
Default command to mv files & folders to dir

On Sun, Sep 25, 2011 at 12:43 AM, Tom Furie <tom@furie.org.uk> wrote:
> On Sat, Sep 24, 2011 at 05:00:47PM +0700, Ivan Shmakov wrote:
>> >>>>> Tom Furie <tom@furie.org.uk> writes:
>> *> What's wrong with 'mv /mnt/deer/* /mnt/deer/zebra'? Sure, it'll
>> *> complain about trying to move zebra to itself, but it works.
>>
>> * * * The other catch is that it won't consider the filenames with a
>> * * * leading dot, such as ‘.bashrc’.
>
> Well, true, but there was no mention of dot files in the original
> problem. Or, as has since transpired, that only some of the files in
> /mnt/deer should be moved to /mnt/deer/zebra.
>
> Ask me a question, I'll give an answer to the question. It's not my
> fault that the wrong question was asked.
>
> Cheers,
> Tom
>
> --
> When neither their poverty nor their honor is touched, the majority of men
> live content.
> * * * * * * * *-- Niccolo Machiavelli
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
>
> iEYEARECAAYFAk5+XQEACgkQ2svup27rrImSDgCfRzB9R+jB6c 21FC3iRQC1Cvyj
> /MsAnRbyCezmsAShm3he0uYZc3MJFSTZ
> =M51U
> -----END PGP SIGNATURE-----
>
>

yes only the files put in /mnt/deer on 22/09/2011 must be moved to
there own folder, but looks like i will have to spend days doing this
manually as zebra is 378 gb big and i copied some files from zebra to
/mnt/deer using "cp" (my bad) and i don't have much room to play with
now as i only have 197gb left in /mnt/deer and a lot of duplicate
files in /mnt/deer and /mnt/deer/zebra


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: CABWh29m88Ox2zhK4qY3LQkgTo7DGrXc6XW7uqYyWv1Y28YJM7 g@mail.gmail.com">http://lists.debian.org/CABWh29m88Ox2zhK4qY3LQkgTo7DGrXc6XW7uqYyWv1Y28YJM7 g@mail.gmail.com
 
Old 09-25-2011, 08:05 AM
Ivan Shmakov
 
Default command to mv files & folders to dir

>>>>> Mark Panen <mark.panen@gmail.com> writes:
>>>>> On Sun, Sep 25, 2011 at 12:43 AM, Tom Furie <tom@furie.org.uk> wrote:
>>>>> On Sat, Sep 24, 2011 at 05:00:47PM +0700, Ivan Shmakov wrote:
>>>>> Tom Furie <tom@furie.org.uk> writes:

>>>> What's wrong with 'mv /mnt/deer/* /mnt/deer/zebra'? Sure, it'll
>>>> complain about trying to move zebra to itself, but it works.

>>> The other catch is that it won't consider the filenames with a
>>> leading dot, such as ‘.bashrc’.

>> Well, true, but there was no mention of dot files in the original
>> problem.

Neither it was stated that there were no such files.

[…]

> yes only the files put in /mnt/deer on 22/09/2011 must be moved to
> there own folder, but looks like i will have to spend days doing this
> manually as zebra is 378 gb big and i copied some files from zebra to
> /mnt/deer using "cp" (my bad) and i don't have much room to play with
> now as i only have 197gb left in /mnt/deer and a lot of duplicate
> files in /mnt/deer and /mnt/deer/zebra

To find the duplicates, the command like the following could
have been used:

$ cd /mnt/deer/
&& find . -type f -not -wholename ./zebra/*
-exec cmp -- {} zebra/{} ;
-print

While to remove them (after double-checking!), the final -print
can be replaced with:

-exec rm -v -- {} +

--
FSF associate member #7257


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 8639fljbde.fsf@gray.siamics.net">http://lists.debian.org/8639fljbde.fsf@gray.siamics.net
 
Old 09-25-2011, 08:32 AM
Ivan Shmakov
 
Default command to mv files & folders to dir

>>>>> Mark Panen <mark.panen@gmail.com> writes:
>>>>> On Sat, Sep 24, 2011 at 1:12 PM, Ivan Shmakov wrote:
>>>>> Mark Panen <mark.panen@gmail.com> writes:
>>>>> On Sat, Sep 24, 2011 at 11:53 AM, Ivan Shmakov wrote:

[Cross-posting to comp.unix.shell for no good reason at all.]

[…]

>>>> $ mkdir -pv -- /mnt/deer/zebra
>>>> && find /mnt/deer/ -maxdepth 1 -mindepth 1 -not -name zebra
>>>> -exec mv --target-directory=/mnt/deer/zebra -- {} +

>>> will this mv only the file/folders created on the 22/09/2011, i
>>> want the older files etc to stay behind.

>> Somehow, I didn't understood that as part of the task.

>> The -ctime constraint to find(1) may be helpful here, like:

>> $ mkdir -pv -- /mnt/deer/zebra
>> && find /mnt/deer/
>> -maxdepth 1 -mindepth 1 -ctime -3 -not -name zebra
>> -exec mv --target-directory=/mnt/deer/zebra -- {} +

>> However, note that the Unix' “change time” is /not/ the file
>> creation time (I know of no Unix filesystem to track the latter),
>> but they /should/ coincide in this particular case.

>> Note also that if the filesystem under /mnt is not a Unix one (such
>> as VFAT), it should be checked whether the ctime is actually set as
>> desired. Like:

>> $ LC_ALL=C stat -- /mnt/deer/foobar

>> (Where foobar is one of the files copied 2011-09-22.) Check if the
>> Change: field is set to 2011-09-22.

> The command made a folder called zebra and put all the contents of
> /mnt/deer in /mnt/deer/zebra so did not achieve my plan, the time
> stamp is now set at 24th for all, according to $ LC_ALL=C stat --
> /mnt/deer/,

Yes, because renaming the file is also counted as a “status
change.”

> ctime -3 seems to be the problem.

I should've cautioned better about the use of change time as a
distinguishing property. Namely, the files that have properly
resided in /mnt/deer/ had to be checked for whether their
timestamps are distinct to those recently copied there.

I see two probably causes for the -ctime failure. First of all,
if the other files were also “changed” recently (e. g., their
content or access mode changed, or they were renamed, or
created), -ctime may have been way too rough a constraint. For
these cases, -cmin may fit better, but it's typically harder to
use.

Also, the filesystem of /mnt/deer/ may somehow lacked the
support for change timestamps, or had them behaving differently.

That being said, there're still ways to recover, though these
are even less straightforward than those for the original
problem.

E. g., a list of all the filenames directly under the original
sources for either /mnt/deer/ or /mnt/deer/zebra/ could be
composed. Like, e. g.:

$ cd /orig/deer/ && find -mindepth 1 -maxdepth 1 -print > /tmp/deer.list
$ cd /orig/zebra/ && find -mindepth 1 -maxdepth 1 -print > /tmp/zebra.list
$

(I hereafter assume that filenames do not contain any special
codes, such as ASCII LF, or Line Feed, or 10.)

Now, as everything is now below /mnt/deer/zebra/, let's try to
bring those originally in /orig/deer/ back into /mnt/deer/:

$ (while read f ; do
mv -vi -- /mnt/deer/zebra/"$f" /mnt/deer/"$f" ;
done) < /tmp/deer.list

Of course, the above will consider only the filenames. It's
impossible to recover if there were two distinct files under
/orig/deer/ and /orig/zebra/ sharing a single (relative)
filename. (Though that's mainly because one of them was written
over the other thanks either to the original cp(1), or to mv(1)
in the recovery attempt above.)

--
FSF associate member #7257


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 86pqiphvjk.fsf@gray.siamics.net">http://lists.debian.org/86pqiphvjk.fsf@gray.siamics.net
 
Old 09-25-2011, 10:41 AM
Ivan Shmakov
 
Default command to mv files & folders to dir

<<< message/rfc822: EXCLUDED >>>
 
Old 09-26-2011, 02:40 AM
shawn wilson
 
Default command to mv files & folders to dir

TIMDOWDY - there's more than one way to do it


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: CAH_OBif-AsWbcjKFs0+ieOWSTX8bj-h2P1a2WqksW+iV7tj7LQ@mail.gmail.com">http://lists.debian.org/CAH_OBif-AsWbcjKFs0+ieOWSTX8bj-h2P1a2WqksW+iV7tj7LQ@mail.gmail.com
 

Thread Tools




All times are GMT. The time now is 04:57 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org