如何移动与文件夹名称相同的文件
例如:
#ls total 2 . .. -rwxr-xr-x 1 root root 230 Jan 16 10:39 food <file to move> drwx--x--x 12 root root 4096 Jan 16 11:25 food <directory>
我想把食物转移到食物目录。
最终产量应该是food/food.ini
当我使用#mv food food/food.ini有一个错误
mv: cannot move `food' to a subdirectory of itself, `food/food.ini'
更新:
这个文件使用以下命令创build:
cp foods1 ../food
父目录中的食品文件夹可用。
我可以使用webmin移动。 但是在使用vi编辑器进行编辑时文件不存在。
你可以尝试这样的事情:
find ./ -name food -type f -exec mv {} ./food/{} \;
我不能在同一文件夹中复制用于创build文件和同名目录的方法,但可以通过使用inode编号而不是其名称来移动文件,例如find命令。
[jpaulus@localhost test]$ ls -lhi total 4.0K 26086760 drwxrwxr-x 2 jpaulus jpaulus 4.0K Jan 15 23:19 test 26086768 -rw-rw-r-- 1 jpaulus jpaulus 0 Jan 15 23:19 test1 find . -inum 26086760 -exec mv {} new_directory/new_filename \; [jpaulus@localhost test]$ ls -lh total 0 -rw-rw-r-- 1 jpaulus jpaulus 0 Jan 15 23:19 test1