0

I want to copy some of the directories in a directory to another directory in that directory itself.

For Example:

I have the structure like the below

myname@compname:~/root/app/pages$ ls

dir1, dir2, dir3

I want the dir1 and dir2 to be moved into dir3 and the final structure has to be as the following:

myname@compname:~/root/app/pages$ ls

dir3

myname@compname:~/root/app/pages/dir3$ ls

dir1, dir2

I know the there are many shell programs for it. but I want this to happen using the CLI itself in just a single lined statement.

gsthina
  • 1,090
  • 8
  • 22

2 Answers2

1
mv dir1 dir2 dir3

will do it

mv dir1 dir2
mv dir2 dir3

does the same thing, in two steps.

Technically mv dir[123] would also do the same thing (for these file names), but would potentially be confusing as the destination is determined alphabetically

Jasen
  • 11,837
  • 2
  • 30
  • 48
0

This is not the perfect answer. But i have done the above with the following code:

myname@compname:~/root/app/pages$ cp -r dir1/ dir3/ && cp -r dir2/ dir3/
myname@compname:~/root/app/pages$ rm -r dir1 && rm -r dir2
myname@compname:~/root/app/pages$ cd dir3 && ls

Other Answers are welcome!

gsthina
  • 1,090
  • 8
  • 22