In comp.os.linux.advocacy, Gordon
<
[email protected]>
wrote
So what makes you think that Linux doesn't have "drag and drop"? Try Ubuntu
in it's current version. NO difference to Windows at all, except the need
for Windows to have AV apps, malware apps etc etc!
Why don't you TRY it instead of making wild and totally ignorant statements?
Because, in this particular case, he's probably right. However,
there's other considerations, depending on the direction
one wants to take this discussion.
[1] That mv could just as easily do 'mv *_jpg ../somewhere-else'.
Three guesses on how well Windows will handle *that*, since
_jpg is not a file extension. (It's not clear Nautilus or
Konqueror can do much with it, either, though Motif-era file
requesters might be able to take the '*_jpg' wildcard.)
[2] With the find command, a lot of things could ensue. For
instance, the command
$ find . -name '*.jpg' -mtime +7 -exec mv {} ../somewhere-else \;
will move any .jpg in the current directory or any subdirectory
thereof (if one doesn't want that one can use -maxdepth 1)
that's more than 7 days old somewhere else. Note that the
.jpg could be anything: text, pictures, scripts, directories.
[3] If one doesn't have file extensions, with Windows one is kinda
stuck. However, in Linux, one can do things like
$ find . -type f -mtime +7 | xargs file | \
grep '^.*: PNG image data, ' | \
awk -F: '{print $1;}' | cpio -oc > archive.cpio
which will take any file older than 7 days, open it, check
to see if it looks like a PNG file, and, if it is, take
it and throw it into a CPIO archive.
The naive user will probably think this is gobbledygook but it's
actually fairly simple, and can be tested easily by
omitting the tail end of the pipeline. Admittedly, tarballs
are more common, and tar's a little harder to feed.
[4] If one has a fancy script and/or program that returns 0 on
success, 1 on failure, one can feed it to find to test files.
$ find . -type f -mtime +7 -exec /home/user/bin/testfile {} \; \
-exec mv {} ../somewhere-else \;
will first run '/home/user/bin/testfile' on any file in the
subtree that's older than 7 days, and, if testfile exits with
0 status, move the file to somewhere-else.
Of course there are many things one can do here, depending on
how fancy one wants to make the script. For example, one
can feed it multiple arguments, and allow it to do all the work:
$ find . -type f -mtime +7 -print0 | \
xargs -0 /home/user/bin/processfiles
(the -print0 and -0 allow xargs to see filenames properly, if
there are spaces in them; it's a blot but necessary for
historical reasons, presumably).
Or one can simply have it read from standard input:
$ find . -type f -mtime +7 -print0 | /home/usr/bin/processfiles --zero
(where --zero is an option passed to the script that it picks up.)
Or find can be put inside the script, making things a little
more convenient for the user.
[5] If one is typing something such as
$ mv *.jpg ../som<TAB>
the shell will either generate the command line
$ mv *.jpg ../somewhere-else
or it will not, in which case another tab will generate output
that looks a bit like:
$ mv *.jpg ../som<TAB><TAB>
../soma ../sombrero ../something-else ../somewhere-else
$ mv *.jpg ../som
This is an innovation not available in the early 80's, though
things such as ICE were being implemented on VMS in the
mid-80's, and ksh was available in the early 90's. I suspect
it came into being around then.
[6] For the simpler stuff, one can do 'locate'. There's some
issues with 'locate', mostly because it's slightly brain-dead
when it comes to searching through filenames (it's basically
a grep through a list generated by 'updatedb' on a periodic
basis), but it's faster than find for those times when one
doesn't need all the flexibility of find, but needs something
more powerful than a simple 'ls'.
[7] To convert these pipelines to automated backups is but a single
step, using 'crontab -e'. (A better solution, admittedly, is
to create a script then feed that to 'crontab -e', but it's
almost as simple; just cut and paste the pipeline into
a text editor window.)
But yes, never mind all that; Windows is easy to use and does
everything.
