官术网_书友最值得收藏!

  • Learn Linux Quickly
  • Ahmed AlKabary
  • 137字
  • 2021-06-11 18:43:49

Renaming files

You can also use the mv command to rename files. For example, if you want to rename the file cats.txt to dogs.txt, you can run the mv cats.txt dogs.txt command:

elliot@ubuntu-linux:~$ mv cats.txt dogs.txt
elliot@ubuntu-linux:~$ cat dogs.txt
I love cars!
I love cats!
I love penguins!
elliot@ubuntu-linux:~$

If you want to rename the directory big to small, you can run the mv big small command:

elliot@ubuntu-linux:~$ mv big small
elliot@ubuntu-linux:~$ ls small
cities d1 d2

elliot@ubuntu-linux:~$

In summary, here is how the mv command works:

  1. If the destination directory exists, the mv command will move the source file(s) to the destination directory.
  2. If the destination directory doesn’t exist, the mv command will rename the source file.

Keep in mind that you can only rename one file (or one directory) at a time.

主站蜘蛛池模板: 绥中县| 大余县| 茂名市| 许昌县| 喀喇| 汝南县| 嘉荫县| 涞水县| 甘孜县| 娄烦县| 当涂县| 开平市| 江源县| 通城县| 磐石市| 临清市| 山阳县| 河间市| 当涂县| 图们市| 平乐县| 和田县| 观塘区| 石景山区| 安宁市| 会理县| 合肥市| 苏尼特左旗| 仁寿县| 柞水县| 枣阳市| 无锡市| 安新县| 潮州市| 高淳县| 丁青县| 阳春市| 利辛县| 临洮县| 上虞市| 吉隆县|