作为一个相当新手的Linux用户,我似乎无法找到如何做到这一点.我试图将一个目录中的唯一文件移动到另一个目录中.例:
$ ls
vehicle car.txt bicycle.txt airplane.html train.docx (more files)
Run Code Online (Sandbox Code Playgroud)
我想在车内使用car.txt,bicycle.txt,airplane.html和train.docx.
现在我通过单独移动文件来做到这一点:
$ mv car.txt vehicle
$ mv bicycle.txt vehicle
...
Run Code Online (Sandbox Code Playgroud)
我怎么能在一行中做到这一点?
Ric*_*ard 16
你可以做
mv car.txt bicycle.txt vehicle/
Run Code Online (Sandbox Code Playgroud)
(请注意,/上面的内容是不必要的,我只是为了确保它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)
Run Code Online (Sandbox Code Playgroud)
Ami*_*wal 13
您可以尝试使用通配符.在下面的代码中,'*'将匹配任何名称以.txt或.docx结尾的文件,并将它们移动到车辆文件夹.
mv *.txt *.docx vehicle/
Run Code Online (Sandbox Code Playgroud)