Linux Bash:将多个不同的文件移动到同一目录中 [英] Linux Bash: Move multiple different files into same directory

查看:47
本文介绍了Linux Bash:将多个不同的文件移动到同一目录中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

As a rather novice Linux user, I can't seem to find how to do this. I am trying to move unique files all in one directory into another directory. Example:

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

我要把car.txt,bicycle.txt,airplane.html和train.docx放在车内.

I want car.txt, bicycle.txt, airplane.html, and train.docx inside vehicle.

现在,我通过分别移动文件来完成此操作:

Right now I do this by moving the files individually:

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

我如何在一排中做到这一点?

How can I do this in one line?

推荐答案

您可以

mv car.txt bicycle.txt vehicle/

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

(Note that the / above is unnecessary, I include it merely to ensure that vehicle is a directory.)

您可以如下进行测试:

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 Bash:将多个不同的文件移动到同一目录中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆