Commit 57e84701 authored by Toby Hodges's avatar Toby Hodges

changed find+xargs exercise to a safer version!

parent 78ea31c4
......@@ -48,7 +48,7 @@ XARGS
3. A better way to back up these files might be to keep the original names while copying them. Make another copy of each file listed in to_be_previewed.txt, adding ".backup" onto the end of each filename. (Hint: remember the "-I" option!)
4. ADVANCED: clean up all these new files by combining the ``find`` tool with ``xargs`` and ``rm`` to search for and delete all files in the current directory that were last modified less than ten minutes ago. BE CAREFUL! (Hint: you'll need to check out the options available for ``find``, and you might consider using the "-p" option with ``xargs`` to help avoid accidentally deleting something that you might regret!)
4. ADVANCED: we've made a bit of a mess now, and it's time to clean up. Make a new directory called 'garbage' and move all these new files into it by combining the ``find`` tool with ``xargs`` and ``mv`` to search for and delete all files in the current directory that were last modified less than ten minutes ago. BE CAREFUL! (Hint: you'll need to check out the options available for ``find``, and you might consider using the "-p" option with ``xargs`` to help avoid accidentally deleting something that you might regret!) Once you've moved the files, check the contents of the 'garbage' directory and, if you're sure that you don't want any of those files anymore, delete them and the directory.
SED
......
......@@ -191,11 +191,18 @@ XARGS
PROTEINS.txt.backup
4. ADVANCED: clean up all these new files by combining the ``find`` tool with ``xargs`` and ``rm`` to search for and delete all files in the current directory that were last modified less than ten minutes ago. BE CAREFUL! (Hint: you'll need to check out the options available for ``find``, and you might consider using the "-p" option with ``xargs`` to help avoid accidentally deleting something that you might regret!)
4. ADVANCED: we've made a bit of a mess now, and it's time to clean up. Make a new directory called 'garbage' and move all these new files into it by combining the ``find`` tool with ``xargs`` and ``mv`` to search for and delete all files in the current directory that were last modified less than ten minutes ago. BE CAREFUL! (Hint: you'll need to check out the options available for ``find``, and you might consider using the "-p" option with ``xargs`` to help avoid accidentally deleting something that you might regret!) Once you've moved the files, check the contents of the 'garbage' directory and, if you're sure that you don't want any of those files anymore, delete them and the directory.
::
$ find . -type f -mtime -10m | xargs -p rm
$ mkdir garbage
$ find . -type f -mtime -10m | xargs -I FILENAME -p mv FILENAME garbage/
$ ls garbage
# either (risky but quicker)
$ rm -r garbage
# or (safer but slower)
$ rm -ri garbage/*
$ rmdir garbage
SED
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment