How can I move files to a single directory and delete the old directory without a special file name?

I use a shell script that takes a single directory called NewData , whatever is inside it, and creates this:

enter image description here

There is one step that I want to add, and I'm not sure how to do it. I want to move the contents of NewData and NewDataCopy to their respective parent directories ( ProtectedOrig and Data ) and delete NewData and NewDataCopy . What commands would I add to my script for this, without naming the names of the files that need to be moved (they will be different each time the script is run)?

If this helps, you can look at the script here . I am grateful for any help I can get!

+4
source share
1 answer

You can move everything without specifying file names using "glob" (otherwise called a "wildcard"). This is a * .

So let's say you are in a DataDirectory . You can move everything from Data/NewDataCopy to Data by doing the following: mv Data/NewDataCopy/* Data/ . Then delete using rmdir Data/NewDataCopy .

Starting with a DataDirectory , to do all you would do is:

 mv Data/NewDataCopy/* Data/ rmdir Data/NewDataCopy mv ProtectedOrig/NewData/* ProtectedOrig/ rmdir ProtectedOrig/NewData 
+8
source

All Articles