Re: command to mv files folders to dir
Mark Panen mark.pa...@gmail.com writes: On Sun, Sep 25, 2011 at 12:43 AM, Tom Furie t...@furie.org.uk wrote: On Sat, Sep 24, 2011 at 05:00:47PM +0700, Ivan Shmakov wrote: Tom Furie t...@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-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/8639fljbde@gray.siamics.net
[g.l.d.user] Re: command to mv files folders to dir
Mark Panen mark.pa...@gmail.com writes: On Sat, Sep 24, 2011 at 1:12 PM, Ivan Shmakov wrote: Mark Panen mark.pa...@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-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/86pqiphvjk@gray.siamics.net
Re: command to mv files folders to dir
---BeginMessage--- 2011-09-25, 15:32(+07), Ivan Shmakov: [...] (I hereafter assume that filenames do not contain any special codes, such as ASCII LF, or Line Feed, or 10.) [...] Or backslashes, or trailing blanks. $ (while read f ; do \ mv -vi -- /mnt/deer/zebra/$f /mnt/deer/$f ; \ done) /tmp/deer.list [...] Also note that mv with -i might read from its standard input, so you may prefer: ret=0 while IFS= read 3 -r f; do mv -vi -- /mnt/deer/zebra/$f /mnt/deer/$f || ret=$? done 3 /tmp/deer.list (exit $ret) See also xargs(1) to avoid having to use a shell loop. -- Stephane -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/86ipogj44o@gray.siamics.net ---End Message---
Re: command to mv files folders to dir
TIMDOWDY - there's more than one way to do it :) -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/cah_obif-aswbcjkfs0+ieowstx8bj-h2p1a2wqksw+iv7tj...@mail.gmail.com
command to mv files folders to dir
Hi, 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. Mark -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/CABWh29=jQBe+-9OC-=N5Y5PMbUJ8BzfkWUUWvzJRm3O=vb7...@mail.gmail.com
Re: command to mv files folders to dir
On Sat, Sep 24, 2011 at 11:40:48AM +0200, Mark Panen wrote: 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. What's wrong with 'mv /mnt/deer/* /mnt/deer/zebra'? Sure, it'll complain about trying to move zebra to itself, but it works. Cheers, Tom -- There is no substitute for good manners, except, perhaps, fast reflexes. signature.asc Description: Digital signature
Re: command to mv files folders to dir
Mark Panen mark.pa...@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 -- {} + -- 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-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/86sjnmjmfy@gray.siamics.net
Re: command to mv files folders to dir
Tom Furie t...@furie.org.uk writes: On Sat, Sep 24, 2011 at 11:40:48AM +0200, Mark Panen wrote: 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. 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’. -- FSF associate member #7257 -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/86k48yjm40@gray.siamics.net
Re: command to mv files folders to dir
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. Greetings, -- Camaleón -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/pan.2011.09.24.10.11...@gmail.com
Re: command to mv files folders to dir
Camaleón noela...@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. 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. Not to mention that the use of Shell keeps one's mind “in shape.” -- FSF associate member #7257 -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/86bouajkoc@gray.siamics.net
Re: command to mv files folders to dir
On Sat, 24 Sep 2011 17:31:47 +0700, Ivan Shmakov wrote: Camaleón noela...@gmail.com writes: On Sat, 24 Sep 2011 11:40:48 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. 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. Midnight Commander is very powerful, I have no complaints over it. It helped me when I first started managing servers with no GUI and still find it very useful to run some tasks and to avoid fat fingers errors. Not to mention that the use of Shell keeps one's mind “in shape.” Both (direct typing and MC) are not mutually exclusive. You can use the best of the two worlds to obtain a better ratio of quickness while keeping you mind in good shape. MC does not need vitamins to keep its brain activity always at 100%. I do. Greetings, -- Camaleón -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/pan.2011.09.24.10.47...@gmail.com
Re: command to mv files folders to dir
On Sat, Sep 24, 2011 at 11:53 AM, Ivan Shmakov i...@gray.siamics.net wrote: Mark Panen mark.pa...@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 -- {} + -- 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-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/86sjnmjmfy@gray.siamics.net will this mv only the file/folders created on the 22/09/2011, i want the older files etc to stay behind. -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/cabwh29mq9hmcxkg1xf9mghuyb5mq0m-wjbv4hr2j9c9zbts...@mail.gmail.com
Re: command to mv files folders to dir
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. (cd /mnt/deer;mkdir zebra;mv * .* zebra) And yes, sure it will complain about . and .. as well as zebra, but it'll work fine for all other files / directories / links. if there are too many files for the wild cards to work, then you'll have a bit more fun, let us know. ;-) Cheers -- Kind Regards AndrewM Andrew McGlashan -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/4e7dba5e.4020...@affinityvision.com.au
Re: command to mv files folders to dir
Mark Panen mark.pa...@gmail.com writes: On Sat, Sep 24, 2011 at 11:53 AM, Ivan Shmakov wrote: Mark Panen mark.pa...@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-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/867h4yjirp@gray.siamics.net
Re: command to mv files folders to dir
Hi, On Sat, Sep 24, 2011 at 05:31:47PM +0700, Ivan Shmakov wrote: Camaleón noela...@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-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20110924171831.gb21...@goofy.lan
Re: command to mv files folders to dir
On Sat, Sep 24, 2011 at 1:12 PM, Ivan Shmakov i...@gray.siamics.net wrote: Mark Panen mark.pa...@gmail.com writes: On Sat, Sep 24, 2011 at 11:53 AM, Ivan Shmakov wrote: Mark Panen mark.pa...@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-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/867h4yjirp@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-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/cabwh29msfzjwlor2kuujegzacyrbzcpqtgcsbdaciwxzdl9...@mail.gmail.com
Re: command to mv files folders to dir
On Sat, Sep 24, 2011 at 05:00:47PM +0700, Ivan Shmakov wrote: Tom Furie t...@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 signature.asc Description: Digital signature
Re: command to mv files folders to dir
On Sun, Sep 25, 2011 at 12:43 AM, Tom Furie t...@furie.org.uk wrote: On Sat, Sep 24, 2011 at 05:00:47PM +0700, Ivan Shmakov wrote: Tom Furie t...@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+jB6c21FC3iRQC1Cvyj /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-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/cabwh29m88ox2zhk4qy3lqkgto7dgrxc6xw7uqyywv1y28yj...@mail.gmail.com