作者:白骨精哥哥_350 | 来源:互联网 | 2023-05-18 03:19
I'm working on a bash script to create a new folder in /tmp/ using the name of a file, and then copy the file inside that folder.
我正在使用bash脚本在/ tmp /中使用文件名创建一个新文件夹,然后将该文件复制到该文件夹中。
#!/bin/bash
MYBASENAME="`basename $1`"
mkdir "/tmp/$MYBASENAME"
for ARG in "$@"
do
mv "$ARG" "/tmp/$MYBASENAME"
done
Behavior:
行为:
When I type in mymove "/home/me/downloads/my new file.zip"
it shows this:
当我输入mymove“/ home / me / downloads / my new file.zip”时,它会显示:
mkdir /tmp/my
new
file.zip
mv: rename /home/me/downloads/my new file.zip to /tmp/my\nnew\nfile.zip:
I have lots of quotes around everything, so I don't understand why this is not working as expected.
我有很多关于一切的引用,所以我不明白为什么这不能按预期工作。
Also, I have the form loop in there in case there are multiple files. I want them all to be copied to the same folder, based on the first argument's basename.
另外,如果有多个文件,我在那里有表单循环。我希望根据第一个参数的basename将它们全部复制到同一个文件夹中。
4 个解决方案