문제

I was reading a book on UNIX when I came across this question. You have a directory structure

    $HOME/a/a/b/c

where the first a is empty. How do you remove it and move the lower directories up? I have looked on the man pages of the commands rmdir and rm but could find nothing. Please help me.

도움이 되었습니까?

해결책

You should move subdirectory before remove parent directory. So..

mv $HOME/a/a $HOME
rmdir $HOME/a

But, this does not work because name a collide.

Rename the parent directory to avoid name collision.

mv $HOME/a $HOME/temp_a
mv $HOME/temp_a/a $HOME
rmdir $HOME/temp_a

다른 팁

Since you cannot move a/a into a, you could instead rename a.

mv a a_
mv a_/a .
rmdir a_
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top