ustclug/Linux101-docs

軟件安裝與文件操作章節的模式匹配部分中命令無效

Ebotian opened this issue · 1 comments

問題:

mv -r *.[ch] /path無效

演示:

yibotian@Nicolette86132:~/files_operate_test$ mv -r *.[ch] ./test2
mv: invalid option -- 'r'
Try 'mv --help' for more information.

附加信息:

yibotian@Nicolette86132:~/files_operate_test$ tree
.
├── test1
│   ├── test1.txt
│   ├── test2
│   │   └── test3
│   ├── test2.txt
│   └── tset2
│       ├── test1.txt
│       └── test2.txt
├── test1.txt
├── test2
│   └── tset2
│       ├── test1.txt
│       └── test2.txt
├── test.c
└── test.h

6 directories, 9 files
yibotian@Nicolette86132:~/files_operate_test$ mv --version
mv (GNU coreutils) 8.32
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Mike Parker, David MacKenzie, and Jim Meyering.

環境:

yibotian@Nicolette86132:~/files_operate_test$ screenfetch
                          ./+o+-       yibotian@Nicolette86132
                  yyyyy- -yyyyyy+      OS: Ubuntu 22.04 jammy
               ://+//////-yyyyyyo      Kernel: x86_64 Linux 5.19.0-45-generic
           .++ .:/++++++/-.+sss/`      Uptime: 4h 35m
         .:++o:  /++++++++/:--:/-      Packages: 1675
        o:+o+:++.`..```.-/oo+++++/     Shell: bash 5.1.16
       .:+o:+o/.          `+sssoo+/    Resolution: 1920x1080
  .++/+:+oo+o:`             /sssooo.   DE: GNOME 41.7
 /+++//+:`oo+o               /::--:.   WM: Mutter
 \+/+o+++`o++o               ++////.   WM Theme: Adwaita
  .++.o+++oo+:`             /dddhhh.   GTK Theme: Yaru-blue-dark [GTK2/3]
       .+.o+oo:.          `oddhhhh+    Icon Theme: Yaru-blue
        \+.++o+o``-````.:ohdhhhhh+     Font: Ubuntu 11
         `:o+++ `ohhhhhhhhyo++os:      Disk: 52G / 175G (31%)
           .o:`.syhhhhhhh/.oo++o`      CPU: Intel Core i5-9300HF @ 8x 4.1GHz [71.0°C]
               /osyyyyyyo++ooo+++/     GPU: GeForce GTX 1650 Mobile / Max-Q
                   ````` +oo+++o\:     RAM: 4080MiB / 7856MiB
                          `oo++.      

修正建議

mv -t /path *.[ch]

修正效果

yibotian@Nicolette86132:~/files_operate_test$ mv -t test2 *.[ch]
yibotian@Nicolette86132:~/files_operate_test$ tree
.
├── test1
│   ├── test1.txt
│   ├── test2
│   │   └── test3
│   ├── test2.txt
│   └── tset2
│       ├── test1.txt
│       └── test2.txt
├── test1.txt
└── test2
    ├── test.c
    ├── test.h
    └── tset2
        ├── test1.txt
        └── test2.txt

6 directories, 9 files
iBug commented

感谢指出,我们没有注意到 mv 没有(一般也不需要)recursive 参数。