0

I have a directory in HDFS with subdirectories that contain part-xxxxx files, created by Spark. I want to move that directory (and everything inside it) into a new directory. How to?


My attempt:

[gsamaras@gwta3000 ~]$ hadoop fs -mv  /projects/landmarks/ /projects/landmarks/all/
mv: ` /projects/landmarks/': No such file or directory
[gsamaras@gwta3000 ~]$ hadoop fs -mv  /projects/landmarks/* /projects/landmarks/all/
mv: ` /projects/landmarks/*': No such file or directory
[gsamaras@gwta3000 ~]$ hadoop fs -mv  /projects/landmarks/*/* /projects/landmarks/all/
mv: ` /projects/landmarks/*/*': No such file or directory
[gsamaras@gwta3000 ~]$ hadoop fs -ls /projects/landmarks/
Found 116 items
drwx------   - gsamaras edugr          0 2016-09-07 18:08 /projects/landmarks/Parthenon
...
1

$ mv projects/landmarks/ projects/landmarks/all/
mv: rename projects/landmarks/ to projects/landmarks/all/landmarks/: Invalid argument
You can not move the Main Directory into one of its Subdirectories.


Directory & Contents
mv /projects/landmarks /projects/landmarks/all

Contents Within Directory
mv /projects/landmarks/* /projects/landmarks/all

Is your desired path projects/landmarks at user or root?
Adding the initial slash is pointing bash to look @ root level for your directory.


With Initial "/" it will point to Root
/Users/Foo/projects/landmarks/all

Without Initial "/" it will point to your current working directory
projects/landmarks/all

  • I am trying to understand how is this different from my attempt... :/ It looks the same! – gsamaras Sep 15 '16 at 2:01
  • There you go, just edited it. Seems like an error in your path. Is /projects/ at root or user level? – CJ Dana Sep 15 '16 at 2:10
  • Thanks for the updated. Unfortunately both approaches raise the same error as in my attempt. The path is somewhere in HDFS. – gsamaras Sep 15 '16 at 2:26
  • I replicated what you did and got: mv: rename projects/landmarks/ to projects/landmarks/all/landmarks/: Invalid argument. Its because you can not move directory1 to directory2 within directory1 – CJ Dana Sep 15 '16 at 2:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.