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

  • 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.

主站蜘蛛池模板: 虎林市| 格尔木市| 大姚县| 达拉特旗| 台安县| 古田县| 蒙山县| 体育| 望都县| 灯塔市| 林州市| 卫辉市| 海林市| 丹寨县| 南城县| 高安市| 通辽市| 交城县| 布尔津县| 自贡市| 龙岩市| 乌兰察布市| 凤山市| 从化市| 额尔古纳市| 城口县| 榆社县| 开封市| 乐都县| 昌乐县| 泸水县| 屏东市| 莱阳市| 卢龙县| 尼木县| 龙泉市| 遂昌县| 白水县| 台中市| 嘉义市| 安顺市|