开发者

How can I move files up one directory and delete old directory without specifically naming files?

开发者 https://www.devze.com 2023-04-11 10:25 出处:网络
I use a shell script that takes a single directory, called NewData, with wha开发者_如何转开发tever is inside of it, and creates this:

I use a shell script that takes a single directory, called NewData, with wha开发者_如何转开发tever is inside of it, and creates this:

How can I move files up one directory and delete old directory without specifically naming files?

There is one step I want to add, and I am not sure how to do it. I want to move the contents of NewData and NewDataCopy into their respective parent directories (ProtectedOrig and Data) and delete NewData and NewDataCopy. What command(s) would I add to my script to do this without specifically naming the files to be moved (they will be different every time I run the script)?

If it would help, you can have a look at the script here. I'm grateful for whatever assistance I can get!


You can move everything without naming the files specifically by using a "glob" (aka a "wildcard"). That's a *.

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

Starting from DataDirectory then to do everything you'd do this:

mv Data/NewDataCopy/* Data/
rmdir Data/NewDataCopy
mv ProtectedOrig/NewData/* ProtectedOrig/
rmdir ProtectedOrig/NewData
0

精彩评论

暂无评论...
验证码 换一张
取 消