跳至主要內容
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?

4563博客

全新的繁體中文 WordPress 網站
  • 首頁
  • 求教下 Linux mv a/* b/* ,文件恢复 和 mv 执行过程
未分類
12 5 月 2020

求教下 Linux mv a/* b/* ,文件恢复 和 mv 执行过程

求教下 Linux mv a/* b/* ,文件恢复 和 mv 执行过程

資深大佬 : server 13

RT.

mv a/* b/* 

今天试了一个 mv 操作,将 a 的内容迁移到空目录 b 下,执行了上面的命令。结果 a 空了, b 目录下有个了*

total 8 ~/space/workspace/t/b ls -an    -rw-r--r-- 1 1000 1000    0  4 月 27 15:44 '*' drwxr-xr-x 2 1000 1000 4096  4 月 27 15:44  . drwxr-xr-x 4 1000 1000 4096  4 月 27 15:44  ..  

大佬有話說 (10)

  • 資深大佬 : taolu

    如果 a 下有多个文件,这样操作是不允许的,因此 a 下原本就一个文件。把 b/* 这个文件重命名即可,`mv * new_name`

  • 資深大佬 : julyclyde

    这里主要的问题是,你误以为
    b/*
    是目标

    但其实 b/*展开之后,最后一个元素才是目标

  • 資深大佬 : ddzzhen

    mv a/* b/

  • 資深大佬 : superrichman

    可能文件已经回不来了? 跟移动到 /dev/null 差不多?

  • 資深大佬 : iFollow

    @taolu
    可是 b 目录下新出来的 * 文件大小是 0 ?

    @julyclyde
    题主说 b 是空目录。

    我在 Ubuntu 16.04 上的测试结果:
    :$ ls a
    a1 a2 a3
    :$
    :$ ls b
    :$
    :$ mv a/* b/*
    mv: target ‘b/*’ is not a directory
    :$
    :$ ls a
    a1 a2 a3
    :$ ls b
    :$

    直接报错了,没有执行操作。

  • 主 資深大佬 : server

    @iFollow zsh 下会报错, 做了 alias
    https://github.com/ohmyzsh/ohmyzsh/blob/9817e1e7ff62494abf9d7c78870e92908567e8f4/plugins/common-aliases/README.md#file-handling

    “`zsh
    mv mv -i Move a file
    “`

    “`bash
    -i, –interactive
    prompt before overwrite

    “`

  • 資深大佬 : taolu

    @server
    “`bash
    [email protected]:~# docker run -it –rm debian bash
    [email protected]:/# cd
    [email protected]:~# mkdir a b
    [email protected]:~# touch a/{1..10}.txt
    [email protected]:~# ls -R a
    a:
    1.txt 10.txt 2.txt 3.txt 4.txt 5.txt 6.txt 7.txt 8.txt 9.txt
    [email protected]:~# /bin/mv a/* b/*
    /bin/mv: target ‘b/*’ is not a directory
    [email protected]:~# /bin/mv -f a/* b/*
    /bin/mv: target ‘b/*’ is not a directory
    [email protected]:~# rm a/{2..10}.txt
    [email protected]:~# ls -R a
    a:
    1.txt
    [email protected]:~# /bin/mv a/* b/*
    [email protected]:~# ls b/
    ‘*’
    “`

  • 主 資深大佬 : server

    @taolu 确实,试了几个发行版,b/* 是 a/1.txt

    说下事情经过
    昨天 有个小伙伴 x51 云一个盘满了,开了一个新盘,就搞了个 mv a/* b/*,后面就是一顿猛虎操作(重启大法),重启后 原目录正常。
    总结下:
    1. 跨盘 mv 没有创建多文件(夹),多版本测试,给 v2 友造成困扰
    2. 很有可能小伙伴 乌龙了
    3. 感谢 @taolu

  • 資深大佬 : c7in7

    我试一下去

  • 資深大佬 : c7in7

    [[email protected] ~]# mkdir a
    [[email protected] ~]# mkdir b
    [[email protected] ~]# cd a
    [[email protected] a]# touch 1.txt 2.txt
    [[email protected] a]# ls
    1.txt 2.txt
    [[email protected] a]# cd ..
    [[email protected] ~]# mv a/* b/*
    mv: 目标”b/*” 不是目录

文章導覽

上一篇文章
下一篇文章

AD

其他操作

  • 登入
  • 訂閱網站內容的資訊提供
  • 訂閱留言的資訊提供
  • WordPress.org 台灣繁體中文

51la

4563博客

全新的繁體中文 WordPress 網站
返回頂端
本站採用 WordPress 建置 | 佈景主題採用 GretaThemes 所設計的 Memory
4563博客
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?
在這裡新增小工具