0

I am total new to shell scripting. I have to write a script that moves every file/folder to the folder above.

d/doc/new_x/x

d/doc/new_y/y

d/doc/new_z/z

x,y,z should be moved to d/doc/

x,y,z can be folders or files

for d in */; do
  mv $d /.
done 

I'm unsure of how to move the directories to the folder above.

Edit: Sorry made mistake in foldernames

its

d/doc/new_x/x and x has to be moved to d/doc

stackov
  • 1
  • 2
  • 1
    Welcome to stackoverflow.com. Please take some time to read [the help pages](http://stackoverflow.com/help), especially the sections named "[What topics can I ask about here?](http://stackoverflow.com/help/on-topic)" and "[What types of questions should I avoid asking?](http://stackoverflow.com/help/dont-ask)". Also please [take the tour](http://stackoverflow.com/tour) and read about [how to ask good questions](http://stackoverflow.com/help/how-to-ask). Lastly please learn how to create a [Minimal, Complete, and Verifiable Example](http://stackoverflow.com/help/mcve). – ArturFH Jun 13 '17 at 13:20
  • Possible duplicate of [Calling shell commands from Ruby](https://stackoverflow.com/questions/2232/calling-shell-commands-from-ruby) – shellter Jun 13 '17 at 15:03

1 Answers1

1

Run in your directory (folder):

mv  -v ./* ../

This will move all the files and directories to the upper directory.

chepner
  • 497,756
  • 71
  • 530
  • 681
alibaba
  • 1,623
  • 2
  • 12
  • 13