gpt4 book ai didi

Linux 狂欢 : Move multiple different files into same directory

转载 作者:IT王子 更新时间:2023-10-29 00:16:00 31 4
gpt4 key购买 nike

作为一个相当新手的 Linux 用户,我似乎无法找到如何做到这一点。我正在尝试将一个目录中的所有唯一文件移动到另一个目录中。示例:

$ ls
vehicle car.txt bicycle.txt airplane.html train.docx (more files)

我想要车内的 car.txt、bicycle.txt、airplane.html 和 train.docx。

现在我通过单独移动文件来做到这一点:

$ mv car.txt vehicle
$ mv bicycle.txt vehicle
...

如何在一行中完成此操作?

最佳答案

你可以做到

mv car.txt bicycle.txt vehicle/

(请注意,上面的 / 是不必要的,我包含它只是为了确保 vehicle 是一个目录。)

您可以按如下方式进行测试:

cd               #Move to home directory
mkdir temp #Make a temporary directory
touch a b c d #Make test (empty) files ('touch' also updates the modification date of an existing file to the current time)
ls #Verify everything is there
mv a b c d temp/ #Move files into temp
ls #See? They are gone.
ls temp/ #Oh, there they are!
rm -rf temp/ #DESTROY (Be very, very careful with this command)

关于Linux 狂欢 : Move multiple different files into same directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41277071/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com