[Linux-disciples] delete a whole lot of files
Karl Sokol
revkarl at gmail.com
Thu Feb 8 14:26:14 EST 2007
Thanks Stephen and Adam for the solution and the tutorial. There are
several nugs in this thread to make life easier.
Ultimately, what I did was test the following command with 'cp' instead of
'mv'. Everything looked fine so I did ...
find ~ -maxdepth 1 -iname '*.jpg' -exec mv '{}' /home/church/jpgs ';'
Followed twenty minutes later by:
rm -r -f /home/church/jpgs/
The -f was there because many of the jpegs were write-protected (throwing
Adam's 'echo' caution to the wind)
It is a little curious that this worked when rm ~/*.jpg didn't, but all's
well that ends well
Btw, I never did recover the deleted pictures that had me using recoverjpeg
in the first place. Oh well. I guess delete means delete.
On 2/7/07, Stephen R Laniel <steve at laniels.org> wrote:
>
> On Wed, Feb 07, 2007 at 03:13:30PM -0600, Karl Sokol wrote:
> > church at ubuntu:~$ find /home/church -iname '*.jpg' -print0 |xargs -i0
> echo rm "
> > {}"
> > find: /home/church/.aptitude: Permission denied
>
> For one thing, I presume all your JPEGs are either in ~, or
> in some specific subfolder of ~ -- 'find' won't be finding
> any under ~church/.aptitude . So you should probably do one
> of two things:
>
> 1) Have 'find' look only under ~, and not under any of ~'s
> subdirectories:
>
> find ~ -maxdepth 1 [rest of arguments]
>
> or
>
> 2) Have it look only under the specific subfolder:
>
> find [subfolder] [rest of arguments]
>
> > xargs: argument line too long
>
> I just tested this out in a directory with more files than
> ls/bash can list. I got the same error as you. I think the
> echo might be the problem. xargs may also be tricky. This
> works for me:
>
> find ~/dir_with_lots_of_files -exec echo rm '{}' \;
>
> I.e., drop the xargs and use -exec. Most of the time you'll
> notice no difference. If you do, come back to us.
>
> > church at ubuntu:~$ find /home/church/ -iname '*.jpg' \ -exec cp '{}'
> /home/church
> > /jpg ';'
> > find: paths must precede expression
>
> Normally one gets 'paths must precede expression' errors
> when one does something like
>
> find -maxdepth 1 ~/some_dir_to_search_in
>
> because 'find' wants you to do
>
> find ~/some_dir_to_search_in -maxdepth 1
>
> So I suspect what's causing you trouble above is the errant
> ' \ ' after the '*.jpg'.
>
> I think you need to get comfortable with 'find'. Why not
> make a test directory like so?
>
> mkdir ~/test_dir
> cd ~/test_dir
> for i in `seq 1 1000`; do touch ~/test_dir/$i; done
> for i in `seq 200 300`; do mv $i{,.jpg}; done
>
> Now you'll have 900 files or so called 1, 2, 3, etc., and
> you'll have 100 or so files called 200.jpg, 201.jpg, etc.
> Now play with that directory as you like. Try
>
> find ~/test_dir -maxdepth 1 -exec echo rm '{}' \;
>
> for instance. Just play around and see if you get
> comfortable with it.
>
> --
> Stephen R. Laniel
> steve at laniels.org
> Cell: +(617) 308-5571
> http://laniels.org/
> PGP key: http://laniels.org/slaniel.key
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.1 (GNU/Linux)
>
> iD8DBQFFykSVHa1lzVGot+YRAvb5AJ9mkY/5jad3ZFveRdG6gdCpAX+oHwCfRzin
> 91z0toyvfoL/aA+tkBlf0S0=
> =s7T/
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> Linux-disciples mailing list
> Linux-disciples at lists.bostoncoop.net
> http://lists.bostoncoop.net/mailman/listinfo/linux-disciples
>
>
--
Grace and Peace,
Rev. Karl Sokol
Franklin Grove UMC
211 N. Spring
Franklin Grove, IL 61031
If you have a talent, that's God's gift to you. If you use that talent,
that's your gift to God.
--
Red Skelton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.bostoncoop.net/pipermail/linux-disciples/attachments/20070208/1bda3f82/attachment.htm
More information about the Linux-disciples
mailing list